1 // System.Net.Sockets.Socket.cs
4 // Phillip Pearson (pp@myelin.co.nz)
5 // Dick Porter <dick@ximian.com>
6 // Gonzalo Paniagua Javier (gonzalo@ximian.com)
8 // Copyright (C) 2001, 2002 Phillip Pearson and Ximian, Inc.
9 // http://www.myelin.co.nz
10 // (c) 2004 Novell, Inc. (http://www.novell.com)
14 // Permission is hereby granted, free of charge, to any person obtaining
15 // a copy of this software and associated documentation files (the
16 // "Software"), to deal in the Software without restriction, including
17 // without limitation the rights to use, copy, modify, merge, publish,
18 // distribute, sublicense, and/or sell copies of the Software, and to
19 // permit persons to whom the Software is furnished to do so, subject to
20 // the following conditions:
22 // The above copyright notice and this permission notice shall be
23 // included in all copies or substantial portions of the Software.
25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 using System.Collections;
35 using System.Collections.Generic;
36 using System.Net.Configuration;
37 using System.Runtime.InteropServices;
38 using System.Threading;
40 namespace System.Net.Sockets
42 public class Socket : IDisposable
54 [StructLayout (LayoutKind.Sequential)]
55 private sealed class SocketAsyncResult: IAsyncResult
57 /* Same structure in the runtime */
62 public GHSocket handle;
65 AsyncCallback callback;
66 WaitHandle waithandle;
68 Exception delayedException;
70 public EndPoint EndPoint; // Connect,ReceiveFrom,SendTo
71 public byte [] Buffer; // Receive,ReceiveFrom,Send,SendTo
72 public int Offset; // Receive,ReceiveFrom,Send,SendTo
73 public int Size; // Receive,ReceiveFrom,Send,SendTo
74 public SocketFlags SockFlags; // Receive,ReceiveFrom,Send,SendTo
84 SocketOperation operation;
87 public SocketAsyncResult (Socket sock, object state, AsyncCallback callback, SocketOperation operation)
90 this.blocking = sock.blocking;
91 this.handle = sock.socket;
93 this.callback = callback;
94 this.operation = operation;
95 SockFlags = SocketFlags.None;
98 public void CheckIfThrowDelayedException ()
100 if (delayedException != null)
101 throw delayedException;
104 throw new SocketException (error);
107 void CompleteAllOnDispose (Queue queue)
109 object [] pending = queue.ToArray ();
113 for (int i = 0; i < pending.Length; i++)
115 SocketAsyncResult ares = (SocketAsyncResult) pending [i];
116 cb = new WaitCallback (ares.CompleteDisposed);
117 ThreadPool.QueueUserWorkItem (cb, null);
121 void CompleteDisposed (object unused)
126 public void Complete ()
128 if (operation != SocketOperation.Receive && Sock.disposed)
129 delayedException = new ObjectDisposedException (Sock.GetType ().ToString ());
134 if (operation == SocketOperation.Receive || operation == SocketOperation.ReceiveFrom)
138 else if (operation == SocketOperation.Send || operation == SocketOperation.SendTo)
145 SocketAsyncCall sac = null;
146 SocketAsyncResult req = null;
149 queue.Dequeue (); // remove ourselves
152 req = (SocketAsyncResult) queue.Peek ();
155 Worker worker = new Worker (req);
156 sac = GetDelegate (worker, req.operation);
160 CompleteAllOnDispose (queue);
166 sac.BeginInvoke (null, req);
169 if (callback != null)
173 SocketAsyncCall GetDelegate (Worker worker, SocketOperation op)
177 case SocketOperation.Receive:
178 return new SocketAsyncCall (worker.Receive);
179 case SocketOperation.ReceiveFrom:
180 return new SocketAsyncCall (worker.ReceiveFrom);
181 case SocketOperation.Send:
182 return new SocketAsyncCall (worker.Send);
183 case SocketOperation.SendTo:
184 return new SocketAsyncCall (worker.SendTo);
186 return null; // never happens
190 public void Complete (bool synch)
192 completed_sync = synch;
196 public void Complete (int total)
202 public void Complete (Exception e, bool synch)
204 completed_sync = synch;
205 delayedException = e;
209 public void Complete (Exception e)
211 delayedException = e;
215 public void Complete (Socket s)
221 public object AsyncState
229 public WaitHandle AsyncWaitHandle
235 if (waithandle == null)
236 waithandle = new ManualResetEvent (completed);
247 public bool CompletedSynchronously
251 return(completed_sync);
255 public bool IsCompleted
266 if (waithandle != null && value)
268 ((ManualResetEvent) waithandle).Set ();
295 private sealed class Worker
297 SocketAsyncResult result;
299 public Worker (SocketAsyncResult ares)
304 public void Accept ()
306 Socket acc_socket = null;
309 acc_socket = result.Sock.Accept ();
317 result.Complete (acc_socket);
320 public void Connect ()
324 result.Sock.Connect (result.EndPoint);
325 result.Sock.connected = true;
337 public void Receive ()
339 // Actual recv() done in the runtime
343 public void Receive ()
348 total = result.Sock.Receive_nochecks (result.Buffer,
359 result.Complete (total);
363 public void ReceiveFrom ()
368 total = result.Sock.ReceiveFrom_nochecks (result.Buffer,
372 ref result.EndPoint);
380 result.Complete (total);
385 void UpdateSendValues (int last_sent)
387 if (result.error == 0)
389 send_so_far += last_sent;
390 result.Offset += last_sent;
391 result.Size -= last_sent;
398 // Actual send() done in the runtime
399 if (result.error == 0)
401 UpdateSendValues (result.Total);
402 if (result.Sock.disposed)
410 SocketAsyncCall sac = new SocketAsyncCall (this.Send);
411 sac.BeginInvoke (null, result);
412 return; // Have to finish writing everything. See bug #74475.
414 result.Total = send_so_far;
424 total = result.Sock.Send_nochecks (result.Buffer,
429 UpdateSendValues (total);
432 SocketAsyncCall sac = new SocketAsyncCall (this.SendTo);
433 sac.BeginInvoke (null, result);
434 return; // Have to finish writing everything. See bug #74475.
436 result.Total = send_so_far;
448 public void SendTo ()
453 total = result.Sock.SendTo_nochecks (result.Buffer,
459 UpdateSendValues (total);
462 SocketAsyncCall sac = new SocketAsyncCall (this.SendTo);
463 sac.BeginInvoke (null, result);
464 return; // Have to finish writing everything. See bug #74475.
466 result.Total = send_so_far;
479 /* the field "socket" is looked up by name by the runtime */
481 private IntPtr socket;
483 private GHSocket socket;
485 private AddressFamily address_family;
486 private SocketType socket_type;
487 private ProtocolType protocol_type;
488 internal bool blocking=true;
489 private Queue readQ = new Queue (2);
490 private Queue writeQ = new Queue (2);
493 delegate void SocketAsyncCall ();
495 * These two fields are looked up by name by the runtime, don't change
496 * their name without also updating the runtime code.
498 private static int ipv4Supported = -1, ipv6Supported = -1;
500 /* When true, the socket was connected at the time of
501 * the last IO operation
503 private bool connected=false;
504 /* true if we called Close_internal */
506 internal bool disposed;
508 /* Used in LocalEndPoint and RemoteEndPoint if the
509 * Mono.Posix assembly is available
511 private static object unixendpoint=null;
512 private static Type unixendpointtype=null;
514 static void AddSockets (ArrayList sockets, IList list, string name)
518 foreach (Socket sock in list)
520 if (sock == null) // MS throws a NullRef
521 throw new ArgumentNullException (name, "Contains a null element");
530 [MethodImplAttribute(MethodImplOptions.InternalCall)]
531 private extern static void Select_internal (ref Socket [] sockets,
535 private static void Select_internal (ref Socket [] sockets, int microSeconds, out int error)
537 GHSocketFactory.Select_internal(ref sockets, microSeconds, out error);
541 public static void Select (IList checkRead, IList checkWrite, IList checkError, int microSeconds)
543 ArrayList list = new ArrayList ();
544 AddSockets (list, checkRead, "checkRead");
545 AddSockets (list, checkWrite, "checkWrite");
546 AddSockets (list, checkError, "checkError");
550 throw new ArgumentNullException ("checkRead, checkWrite, checkError",
551 "All the lists are null or empty.");
556 * The 'sockets' array contains: READ socket 0-n, null,
557 * WRITE socket 0-n, null,
558 * ERROR socket 0-n, null
560 Socket [] sockets = (Socket []) list.ToArray (typeof (Socket));
561 Select_internal (ref sockets, microSeconds, out error);
564 throw new SocketException (error);
566 if (checkRead != null)
569 if (checkWrite != null)
572 if (checkError != null)
579 int count = sockets.Length;
580 IList currentList = checkRead;
581 for (int i = 0; i < count; i++)
583 Socket sock = sockets [i];
586 currentList = (mode == 0) ? checkWrite : checkError;
591 if (currentList != null)
593 sock.connected = true;
594 currentList.Add (sock);
605 ass = Assembly.Load (Consts.AssemblyMono_Posix);
606 } catch (FileNotFoundException) {
610 unixendpointtype=ass.GetType("Mono.Posix.UnixEndPoint");
612 /* The endpoint Create() method is an instance
615 Type[] arg_types=new Type[1];
616 arg_types[0]=typeof(string);
617 ConstructorInfo cons=unixendpointtype.GetConstructor(arg_types);
619 object[] args=new object[1];
622 unixendpoint=cons.Invoke(args);
627 // private constructor used by Accept, which already
628 // has a socket handle to use
629 private Socket(AddressFamily family, SocketType type,
630 ProtocolType proto, IntPtr sock)
632 // private constructor used by Accept, which already
633 // has a socket handle to use
634 private Socket(AddressFamily family, SocketType type,
635 ProtocolType proto, GHSocket sock)
638 address_family=family;
648 // Creates a new system socket, returning the handle
649 [MethodImplAttribute(MethodImplOptions.InternalCall)]
650 private extern IntPtr Socket_internal(AddressFamily family,
655 private GHSocket Socket_internal(AddressFamily family,
660 return GHSocketFactory.Socket_internal(family, type, proto, out error);
664 public Socket(AddressFamily family, SocketType type,
667 address_family=family;
672 socket=Socket_internal(family, type, proto, out error);
674 throw new SocketException (error);
678 public AddressFamily AddressFamily
682 return(address_family);
687 // Returns the amount of data waiting to be read on socket
688 [MethodImplAttribute(MethodImplOptions.InternalCall)]
689 private extern static int Available_internal(IntPtr socket,
692 private int Available_internal(GHSocket socket, out int error)
694 return socket.Available_internal(out error);
706 ret = Available_internal(socket, out error);
710 throw new SocketException (error);
718 [MethodImplAttribute(MethodImplOptions.InternalCall)]
719 private extern static void Blocking_internal(IntPtr socket,
723 private void Blocking_internal(GHSocket socket, bool block, out int error)
725 socket.Blocking_internal(block, out error);
741 Blocking_internal(socket, value, out error);
744 throw new SocketException (error);
751 public bool Connected
772 throw new NotImplementedException ();
776 internal GHSocket GHHandle
786 // Returns the local endpoint details in addr and port
787 [MethodImplAttribute(MethodImplOptions.InternalCall)]
788 private extern static SocketAddress LocalEndPoint_internal(IntPtr socket, out int error);
790 [MonoTODO("Support non-IP endpoints")]
791 public EndPoint LocalEndPoint
795 if (disposed && closed)
796 throw new ObjectDisposedException (GetType ().ToString ());
801 sa=LocalEndPoint_internal(socket, out error);
804 throw new SocketException (error);
807 if(sa.Family==AddressFamily.InterNetwork || sa.Family==AddressFamily.InterNetworkV6) {
808 // Stupidly, EndPoint.Create() is an
810 return new IPEndPoint(0, 0).Create(sa);
811 } else if (sa.Family==AddressFamily.Unix &&
812 unixendpoint!=null) {
813 return((EndPoint)unixendpointtype.InvokeMember("Create", BindingFlags.InvokeMethod|BindingFlags.Instance|BindingFlags.Public, null, unixendpoint, new object[] {sa}));
815 throw new NotImplementedException();
820 private EndPoint LocalEndPoint_internal(GHSocket socket, out int error)
822 return socket.LocalEndPoint_internal(out error);
825 public EndPoint LocalEndPoint
833 EndPoint ret = LocalEndPoint_internal(socket, out error);
837 throw new SocketException (error);
845 public ProtocolType ProtocolType
849 return(protocol_type);
854 // Returns the remote endpoint details in addr and port
855 [MethodImplAttribute(MethodImplOptions.InternalCall)]
856 private extern static SocketAddress RemoteEndPoint_internal(IntPtr socket, out int error);
858 [MonoTODO("Support non-IP endpoints")]
859 public EndPoint RemoteEndPoint
863 if (disposed && closed)
864 throw new ObjectDisposedException (GetType ().ToString ());
869 sa=RemoteEndPoint_internal(socket, out error);
872 throw new SocketException (error);
875 if(sa.Family==AddressFamily.InterNetwork || sa.Family==AddressFamily.InterNetworkV6 ) {
876 // Stupidly, EndPoint.Create() is an
878 return new IPEndPoint(0, 0).Create(sa);
879 } else if (sa.Family==AddressFamily.Unix &&
880 unixendpoint!=null) {
881 return((EndPoint)unixendpointtype.InvokeMember("Create", BindingFlags.InvokeMethod|BindingFlags.Instance|BindingFlags.Public, null, unixendpoint, new object[] {sa}));
883 throw new NotImplementedException();
888 private EndPoint RemoteEndPoint_internal(GHSocket socket, out int error)
890 return socket.RemoteEndPoint_internal(out error);
893 public EndPoint RemoteEndPoint
901 EndPoint ret = RemoteEndPoint_internal(socket, out error);
905 throw new SocketException (error);
913 public SocketType SocketType
921 public static bool SupportsIPv4
925 CheckProtocolSupport();
926 return ipv4Supported == 1;
930 public static bool SupportsIPv6
934 CheckProtocolSupport();
935 return ipv6Supported == 1;
939 internal static void CheckProtocolSupport()
941 if(ipv4Supported == -1)
945 Socket tmp = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
956 if(ipv6Supported == -1)
958 #if CONFIGURATION_DEP
959 SettingsSection config;
960 config = (SettingsSection) System.Configuration.ConfigurationManager.GetSection ("system.net/settings");
962 ipv6Supported = config.Ipv6.Enabled ? -1 : 0;
964 NetConfig config = (NetConfig)System.Configuration.ConfigurationSettings.GetConfig("system.net/settings");
967 ipv6Supported = config.ipv6Enabled?-1:0;
969 if(ipv6Supported != 0)
973 Socket tmp = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp);
984 // Creates a new system socket, returning the handle
985 [MethodImplAttribute(MethodImplOptions.InternalCall)]
986 private extern static IntPtr Accept_internal(IntPtr sock,
989 private GHSocket Accept_internal(GHSocket sock, out int error)
991 return sock.Accept_internal(out error);
995 public Socket Accept()
1001 IntPtr sock = (IntPtr) (-1);
1003 GHSocket sock = null;
1005 sock = Accept_internal(socket, out error);
1007 throw new SocketException (error);
1010 Socket accepted = new Socket(this.AddressFamily,
1012 this.ProtocolType, sock);
1014 accepted.Blocking = this.Blocking;
1018 public IAsyncResult BeginAccept(AsyncCallback callback,
1022 EnsureStillUsable();
1024 SocketAsyncResult req = new SocketAsyncResult (this, state, callback, SocketOperation.Accept);
1025 Worker worker = new Worker (req);
1026 SocketAsyncCall sac = new SocketAsyncCall (worker.Accept);
1027 sac.BeginInvoke (null, req);
1031 public IAsyncResult BeginConnect(EndPoint end_point,
1032 AsyncCallback callback,
1036 EnsureStillUsable();
1038 if (end_point == null)
1039 throw new ArgumentNullException ("end_point");
1041 SocketAsyncResult req = new SocketAsyncResult (this, state, callback, SocketOperation.Connect);
1042 req.EndPoint = end_point;
1044 // Bug #75154: Connect() should not succeed for .Any addresses.
1045 if (end_point is IPEndPoint)
1047 IPEndPoint ep = (IPEndPoint) end_point;
1048 if (ep.Address.Equals (IPAddress.Any) || ep.Address.Equals (IPAddress.IPv6Any))
1050 req.Complete (new SocketException (10049), true);
1059 SocketAddress serial = end_point.Serialize ();
1060 Connect_internal (socket, serial, out error);
1062 Connect_internal (socket, end_point, out error);
1068 req.Complete (true);
1070 else if (error != 10036 && error != 10035)
1074 req.Complete (new SocketException (error), true);
1078 if (blocking || error == 10036 || error == 10035)
1082 Worker worker = new Worker (req);
1083 SocketAsyncCall sac = new SocketAsyncCall (worker.Connect);
1084 sac.BeginInvoke (null, req);
1090 public IAsyncResult BeginReceive(byte[] buffer, int offset,
1092 SocketFlags socket_flags,
1093 AsyncCallback callback,
1097 EnsureStillUsable();
1100 throw new ArgumentNullException ("buffer");
1102 if (offset < 0 || offset > buffer.Length)
1103 throw new ArgumentOutOfRangeException ("offset");
1105 if (size < 0 || offset + size > buffer.Length)
1106 throw new ArgumentOutOfRangeException ("size");
1108 SocketAsyncResult req;
1111 req = new SocketAsyncResult (this, state, callback, SocketOperation.Receive);
1112 req.Buffer = buffer;
1113 req.Offset = offset;
1115 req.SockFlags = socket_flags;
1116 readQ.Enqueue (req);
1117 if (readQ.Count == 1)
1119 Worker worker = new Worker (req);
1120 SocketAsyncCall sac = new SocketAsyncCall (worker.Receive);
1121 sac.BeginInvoke (null, req);
1128 public IAsyncResult BeginReceiveFrom(byte[] buffer, int offset,
1130 SocketFlags socket_flags,
1131 ref EndPoint remote_end,
1132 AsyncCallback callback,
1135 EnsureStillUsable();
1138 throw new ArgumentNullException ("buffer");
1141 throw new ArgumentOutOfRangeException ("offset must be >= 0");
1144 throw new ArgumentOutOfRangeException ("size must be >= 0");
1146 if (offset + size > buffer.Length)
1147 throw new ArgumentOutOfRangeException ("offset + size exceeds the buffer length");
1149 SocketAsyncResult req;
1152 req = new SocketAsyncResult (this, state, callback, SocketOperation.ReceiveFrom);
1153 req.Buffer = buffer;
1154 req.Offset = offset;
1156 req.SockFlags = socket_flags;
1157 req.EndPoint = remote_end;
1158 readQ.Enqueue (req);
1159 if (readQ.Count == 1)
1161 Worker worker = new Worker (req);
1162 SocketAsyncCall sac = new SocketAsyncCall (worker.ReceiveFrom);
1163 sac.BeginInvoke (null, req);
1169 public IAsyncResult BeginSend (byte[] buffer, int offset, int size, SocketFlags socket_flags,
1170 AsyncCallback callback, object state)
1172 EnsureStillUsable();
1175 throw new ArgumentNullException ("buffer");
1178 throw new ArgumentOutOfRangeException ("offset must be >= 0");
1181 throw new ArgumentOutOfRangeException ("size must be >= 0");
1183 if (offset + size > buffer.Length)
1184 throw new ArgumentOutOfRangeException ("offset + size exceeds the buffer length");
1186 SocketAsyncResult req;
1189 req = new SocketAsyncResult (this, state, callback, SocketOperation.Send);
1190 req.Buffer = buffer;
1191 req.Offset = offset;
1193 req.SockFlags = socket_flags;
1194 writeQ.Enqueue (req);
1195 if (writeQ.Count == 1)
1197 Worker worker = new Worker (req);
1198 SocketAsyncCall sac = new SocketAsyncCall (worker.Send);
1199 sac.BeginInvoke (null, req);
1205 public IAsyncResult BeginSendTo(byte[] buffer, int offset,
1207 SocketFlags socket_flags,
1208 EndPoint remote_end,
1209 AsyncCallback callback,
1212 EnsureStillUsable();
1215 throw new ArgumentNullException ("buffer");
1218 throw new ArgumentOutOfRangeException ("offset must be >= 0");
1221 throw new ArgumentOutOfRangeException ("size must be >= 0");
1223 if (offset + size > buffer.Length)
1224 throw new ArgumentOutOfRangeException ("offset + size exceeds the buffer length");
1226 SocketAsyncResult req;
1229 req = new SocketAsyncResult (this, state, callback, SocketOperation.SendTo);
1230 req.Buffer = buffer;
1231 req.Offset = offset;
1233 req.SockFlags = socket_flags;
1234 req.EndPoint = remote_end;
1235 writeQ.Enqueue (req);
1236 if (writeQ.Count == 1)
1238 Worker worker = new Worker (req);
1239 SocketAsyncCall sac = new SocketAsyncCall (worker.SendTo);
1240 sac.BeginInvoke (null, req);
1247 // Creates a new system socket, returning the handle
1248 [MethodImplAttribute(MethodImplOptions.InternalCall)]
1249 private extern static void Bind_internal(IntPtr sock,
1253 public void Bind(EndPoint local_end)
1255 if (disposed && closed)
1256 throw new ObjectDisposedException (GetType ().ToString ());
1258 if(local_end==null) {
1259 throw new ArgumentNullException("local_end");
1264 Bind_internal(socket, local_end.Serialize(),
1268 throw new SocketException (error);
1272 private void Bind_internal(GHSocket sock,
1276 sock.Bind_internal(sa, out error);
1279 public void Bind(EndPoint local_end)
1281 EnsureStillUsable();
1283 if(local_end==null) {
1284 throw new ArgumentNullException("local_end");
1289 Bind_internal(socket, local_end,
1293 throw new SocketException (error);
1299 // Closes the socket
1300 [MethodImplAttribute(MethodImplOptions.InternalCall)]
1301 private extern static void Close_internal(IntPtr socket,
1304 private void Close_internal(GHSocket socket, out int error)
1306 socket.Close_internal(out error);
1312 ((IDisposable) this).Dispose ();
1316 // Connects to the remote address
1317 [MethodImplAttribute(MethodImplOptions.InternalCall)]
1318 private extern static void Connect_internal(IntPtr sock,
1322 private void Connect_internal(GHSocket sock,
1326 sock.Connect_internal(sa, out error);
1330 public void Connect(EndPoint remote_end)
1332 EnsureStillUsable();
1334 if(remote_end==null) {
1335 throw new ArgumentNullException("remote_end");
1338 if (remote_end is IPEndPoint) {
1339 IPEndPoint ep = (IPEndPoint) remote_end;
1340 if (ep.Address.Equals (IPAddress.Any) || ep.Address.Equals (IPAddress.IPv6Any))
1341 throw new SocketException (10049);
1347 Connect_internal (socket, remote_end.Serialize(), out error);
1349 Connect_internal (socket, remote_end, out error);
1352 throw new SocketException (error);
1359 public void ChangeToSSL()
1363 GHSocket tmp = socket.ChangeToSSL(null);
1372 Console.WriteLine("Caught exception during ChangeToSSL: {0}, {1}", e.GetType(), e.Message);
1374 throw new SocketException(10045);
1379 public Socket EndAccept(IAsyncResult result)
1381 EnsureStillUsable();
1384 throw new ArgumentNullException ("result");
1386 SocketAsyncResult req = result as SocketAsyncResult;
1388 throw new ArgumentException ("Invalid IAsyncResult", "result");
1390 if (!result.IsCompleted)
1391 result.AsyncWaitHandle.WaitOne();
1393 req.CheckIfThrowDelayedException();
1397 public void EndConnect(IAsyncResult result) {
1398 EnsureStillUsable();
1401 throw new ArgumentNullException ("result");
1403 SocketAsyncResult req = result as SocketAsyncResult;
1405 throw new ArgumentException ("Invalid IAsyncResult", "result");
1407 if (!result.IsCompleted)
1408 result.AsyncWaitHandle.WaitOne();
1410 req.CheckIfThrowDelayedException();
1413 [MonoNotSupported ("")]
1414 public void EndDisconnect (IAsyncResult asyncResult)
1416 throw new NotImplementedException ();
1419 public int EndReceive(IAsyncResult result) {
1420 EnsureStillUsable();
1423 throw new ArgumentNullException ("result");
1425 SocketAsyncResult req = result as SocketAsyncResult;
1427 throw new ArgumentException ("Invalid IAsyncResult", "result");
1429 if (!result.IsCompleted)
1430 result.AsyncWaitHandle.WaitOne();
1432 req.CheckIfThrowDelayedException();
1436 public int EndReceiveFrom(IAsyncResult result,
1437 ref EndPoint end_point)
1439 EnsureStillUsable();
1442 throw new ArgumentNullException ("result");
1444 SocketAsyncResult req = result as SocketAsyncResult;
1446 throw new ArgumentException ("Invalid IAsyncResult", "result");
1448 if (!result.IsCompleted)
1449 result.AsyncWaitHandle.WaitOne();
1451 req.CheckIfThrowDelayedException();
1452 end_point = req.EndPoint;
1456 public int EndSend(IAsyncResult result) {
1457 EnsureStillUsable();
1460 throw new ArgumentNullException ("result");
1462 SocketAsyncResult req = result as SocketAsyncResult;
1464 throw new ArgumentException ("Invalid IAsyncResult", "result");
1466 if (!result.IsCompleted)
1467 result.AsyncWaitHandle.WaitOne();
1469 req.CheckIfThrowDelayedException();
1473 public int EndSendTo(IAsyncResult result) {
1474 EnsureStillUsable();
1477 throw new ArgumentNullException ("result");
1479 SocketAsyncResult req = result as SocketAsyncResult;
1481 throw new ArgumentException ("Invalid IAsyncResult", "result");
1483 if (!result.IsCompleted)
1484 result.AsyncWaitHandle.WaitOne();
1486 req.CheckIfThrowDelayedException();
1491 [MethodImplAttribute(MethodImplOptions.InternalCall)]
1492 private extern static void GetSocketOption_obj_internal(IntPtr socket, SocketOptionLevel level, SocketOptionName name, out object obj_val, out int error);
1493 [MethodImplAttribute(MethodImplOptions.InternalCall)]
1494 private extern static void GetSocketOption_arr_internal(IntPtr socket, SocketOptionLevel level, SocketOptionName name, ref byte[] byte_val, out int error);
1496 private void GetSocketOption_obj_internal(GHSocket socket, SocketOptionLevel level,
1497 SocketOptionName name, out object obj_val, out int error)
1499 EnsureStillUsable();
1501 socket.GetSocketOption_obj_internal(level, name, out obj_val, out error);
1503 private void GetSocketOption_arr_internal(GHSocket socket, SocketOptionLevel level,
1504 SocketOptionName name, ref byte[] byte_val, out int error)
1506 EnsureStillUsable();
1508 socket.GetSocketOption_arr_internal(level, name, ref byte_val, out error);
1512 public object GetSocketOption(SocketOptionLevel level,
1513 SocketOptionName name) {
1517 GetSocketOption_obj_internal(socket, level, name,
1518 out obj_val, out error);
1521 throw new SocketException (error);
1524 if(name==SocketOptionName.Linger) {
1525 return((LingerOption)obj_val);
1526 } else if (name==SocketOptionName.AddMembership ||
1527 name==SocketOptionName.DropMembership) {
1528 return((MulticastOption)obj_val);
1529 } else if (obj_val is int) {
1530 return((int)obj_val);
1536 public void GetSocketOption(SocketOptionLevel level,
1537 SocketOptionName name,
1541 GetSocketOption_arr_internal(socket, level, name,
1542 ref opt_value, out error);
1545 throw new SocketException (error);
1549 public byte[] GetSocketOption(SocketOptionLevel level,
1550 SocketOptionName name,
1552 byte[] byte_val=new byte[length];
1555 GetSocketOption_arr_internal(socket, level, name,
1556 ref byte_val, out error);
1559 throw new SocketException (error);
1566 // See Socket.IOControl, WSAIoctl documentation in MSDN. The
1567 // common options between UNIX and Winsock are FIONREAD,
1568 // FIONBIO and SIOCATMARK. Anything else will depend on the
1570 [MethodImplAttribute(MethodImplOptions.InternalCall)]
1571 extern static int WSAIoctl (IntPtr sock, int ioctl_code,
1572 byte [] input, byte [] output,
1575 int WSAIoctl (GHSocket sock, int ioctl_code,
1576 byte [] input, byte [] output,
1579 return sock.WSAIoctl(ioctl_code, input, output, out error);
1583 public int IOControl (int ioctl_code, byte [] in_value, byte [] out_value)
1586 throw new ObjectDisposedException (GetType ().ToString ());
1589 int result = WSAIoctl (socket, ioctl_code, in_value,
1590 out_value, out error);
1593 throw new SocketException (error);
1597 throw new InvalidOperationException ("Must use Blocking property instead.");
1602 [MonoNotSupported ("")]
1603 public int IOControl (IOControlCode ioControlCode, byte [] optionInValue, byte [] optionOutValue)
1605 throw new NotImplementedException ();
1609 [MethodImplAttribute(MethodImplOptions.InternalCall)]
1610 private extern static void Listen_internal(IntPtr sock,
1614 private void Listen_internal(GHSocket sock,
1618 EnsureStillUsable();
1620 sock.Listen_internal(backlog, out error);
1624 public void Listen(int backlog)
1628 Listen_internal(socket, backlog, out error);
1631 throw new SocketException (error);
1636 [MethodImplAttribute(MethodImplOptions.InternalCall)]
1637 extern static bool Poll_internal (IntPtr socket, SelectMode mode, int timeout, out int error);
1639 bool Poll_internal (GHSocket socket, SelectMode mode, int timeout, out int error)
1641 return socket.Poll_internal(mode, timeout, this, out error);
1645 public bool Poll(int time_us, SelectMode mode)
1647 EnsureStillUsable();
1649 if (mode != SelectMode.SelectRead &&
1650 mode != SelectMode.SelectWrite &&
1651 mode != SelectMode.SelectError)
1652 throw new NotSupportedException ("'mode' parameter is not valid.");
1655 bool result = Poll_internal (socket, mode, time_us, out error);
1657 throw new SocketException (error);
1659 if (result == true) {
1660 /* Update the connected state; for
1661 * non-blocking Connect()s this is
1662 * when we can find out that the
1663 * connect succeeded.
1671 public int Receive (byte [] buf)
1673 EnsureStillUsable();
1676 throw new ArgumentNullException ("buf");
1678 return Receive_nochecks (buf, 0, buf.Length, SocketFlags.None);
1681 public int Receive (byte [] buf, SocketFlags flags)
1683 EnsureStillUsable();
1686 throw new ArgumentNullException ("buf");
1688 return Receive_nochecks (buf, 0, buf.Length, flags);
1691 public int Receive (byte [] buf, int size, SocketFlags flags)
1693 EnsureStillUsable();
1696 throw new ArgumentNullException ("buf");
1698 if (size < 0 || size > buf.Length)
1699 throw new ArgumentOutOfRangeException ("size");
1701 return Receive_nochecks (buf, 0, size, flags);
1705 [MethodImplAttribute(MethodImplOptions.InternalCall)]
1706 private extern static int Receive_internal(IntPtr sock,
1713 private int Receive_internal(GHSocket sock,
1720 return sock.Receive_internal(buffer, offset, count, flags, out error);
1724 public int Receive (byte [] buf, int offset, int size, SocketFlags flags)
1726 EnsureStillUsable();
1729 throw new ArgumentNullException ("buf");
1731 if (offset < 0 || offset > buf.Length)
1732 throw new ArgumentOutOfRangeException ("offset");
1734 if (size < 0 || offset + size > buf.Length)
1735 throw new ArgumentOutOfRangeException ("size");
1737 return Receive_nochecks (buf, offset, size, flags);
1740 int Receive_nochecks (byte [] buf, int offset, int size, SocketFlags flags)
1743 ret = Receive_internal (socket, buf, offset, size, flags, out error);
1746 if (error != 10035 && error != 10036) // WSAEWOULDBLOCK && WSAEINPROGRESS
1749 throw new SocketException (error);
1757 public int ReceiveFrom (byte [] buf, ref EndPoint remote_end)
1760 throw new ArgumentNullException ("buf");
1762 if (remote_end == null)
1763 throw new ArgumentNullException ("remote_end");
1765 return ReceiveFrom_nochecks (buf, 0, buf.Length, SocketFlags.None, ref remote_end);
1768 public int ReceiveFrom (byte [] buf, SocketFlags flags, ref EndPoint remote_end)
1771 throw new ArgumentNullException ("buf");
1773 if (remote_end == null)
1774 throw new ArgumentNullException ("remote_end");
1777 return ReceiveFrom_nochecks (buf, 0, buf.Length, flags, ref remote_end);
1780 public int ReceiveFrom(byte[] buf, int size, SocketFlags flags,
1781 ref EndPoint remote_end)
1784 throw new ArgumentNullException ("buf");
1786 if (remote_end == null)
1787 throw new ArgumentNullException ("remote_end");
1789 if (size < 0 || size > buf.Length)
1790 throw new ArgumentOutOfRangeException ("size");
1792 return ReceiveFrom_nochecks (buf, 0, size, flags, ref remote_end);
1796 [MethodImplAttribute(MethodImplOptions.InternalCall)]
1797 private extern static int RecvFrom_internal(IntPtr sock,
1802 ref SocketAddress sockaddr,
1805 private int RecvFrom_internal(GHSocket sock,
1810 ref SocketAddress sockaddr,
1813 return sock.RecvFrom_internal(buffer, offset, count, flags, ref sockaddr, out error);
1818 public int ReceiveFrom(byte[] buf, int offset, int size, SocketFlags flags,
1819 ref EndPoint remote_end)
1821 EnsureStillUsable();
1824 throw new ArgumentNullException ("buf");
1826 if (remote_end == null)
1827 throw new ArgumentNullException ("remote_end");
1829 if (offset < 0 || offset > buf.Length)
1830 throw new ArgumentOutOfRangeException ("offset");
1832 if (size < 0 || offset + size > buf.Length)
1833 throw new ArgumentOutOfRangeException ("size");
1835 return ReceiveFrom_nochecks (buf, offset, size, flags, ref remote_end);
1838 int ReceiveFrom_nochecks (byte [] buf, int offset, int size, SocketFlags flags,
1839 ref EndPoint remote_end)
1841 EnsureStillUsable();
1843 SocketAddress sockaddr=remote_end.Serialize();
1846 cnt = RecvFrom_internal (socket, buf, offset, size, flags, ref sockaddr, out error);
1849 if (error != 10035 && error != 10036) // WSAEWOULDBLOCK && WSAEINPROGRESS
1852 throw new SocketException (error);
1857 // If sockaddr is null then we're a connection
1858 // oriented protocol and should ignore the
1859 // remote_end parameter (see MSDN
1860 // documentation for Socket.ReceiveFrom(...) )
1862 if ( sockaddr != null ) {
1863 // Stupidly, EndPoint.Create() is an
1865 remote_end=remote_end.Create(sockaddr);
1871 public int Send (byte [] buf)
1873 EnsureStillUsable();
1876 throw new ArgumentNullException ("buf");
1878 return Send_nochecks (buf, 0, buf.Length, SocketFlags.None);
1881 public int Send (byte [] buf, SocketFlags flags)
1883 EnsureStillUsable();
1886 throw new ArgumentNullException ("buf");
1888 return Send_nochecks (buf, 0, buf.Length, flags);
1891 public int Send (byte [] buf, int size, SocketFlags flags)
1893 EnsureStillUsable();
1896 throw new ArgumentNullException ("buf");
1898 if (size < 0 || size > buf.Length)
1899 throw new ArgumentOutOfRangeException ("size");
1901 return Send_nochecks (buf, 0, size, flags);
1904 [MonoNotSupported ("")]
1905 public int Send (byte [] buffer, int offset, int size, SocketFlags socketFlags, out SocketError errorCode)
1907 throw new NotImplementedException ();
1910 [MonoNotSupported ("")]
1911 public int Send (IList<ArraySegment<byte>> buffers)
1913 throw new NotImplementedException ();
1916 [MonoNotSupported ("")]
1917 public int Send (IList<ArraySegment<byte>> buffers, SocketFlags socketFlags)
1919 throw new NotImplementedException ();
1922 //[CLSCompliantAttribute (false)]
1923 [MonoNotSupported ("")]
1924 public int Send (IList<ArraySegment<byte>> buffers, SocketFlags socketFlags, out SocketError errorCode)
1926 throw new NotImplementedException ();
1929 [MonoNotSupported ("")]
1930 public int Receive (byte [] buffer, int offset, int size, SocketFlags socketFlags, out SocketError errorCode)
1932 throw new NotImplementedException ();
1935 [MonoNotSupported ("")]
1936 public int Receive (IList<ArraySegment<byte>> buffers)
1938 throw new NotImplementedException ();
1941 //[CLSCompliantAttribute (false)]
1942 [MonoNotSupported ("")]
1943 public int Receive (IList<ArraySegment<byte>> buffers, SocketFlags socketFlags)
1945 throw new NotImplementedException ();
1948 //[CLSCompliantAttribute (false)]
1949 [MonoNotSupported ("")]
1950 public int Receive (IList<ArraySegment<byte>> buffers, SocketFlags socketFlags, out SocketError errorCode)
1952 throw new NotImplementedException ();
1955 [MonoNotSupported ("")]
1956 public int ReceiveMessageFrom (byte [] buffer, int offset, int size, ref SocketFlags socketFlags, ref EndPoint remoteEP, out IPPacketInformation ipPacketInformation)
1958 throw new NotImplementedException ();
1961 [MonoNotSupported ("")]
1962 public IAsyncResult BeginReceiveMessageFrom (byte [] buffer, int offset, int size, SocketFlags socketFlags, ref EndPoint remoteEP, AsyncCallback callback, Object state)
1964 throw new NotImplementedException ();
1967 [MonoNotSupported ("")]
1968 public int EndReceiveMessageFrom (IAsyncResult asyncResult, ref SocketFlags socketFlags, ref EndPoint endPoint, out IPPacketInformation ipPacketInformation)
1970 throw new NotImplementedException ();
1974 [MethodImplAttribute(MethodImplOptions.InternalCall)]
1975 private extern static int Send_internal(IntPtr sock,
1976 byte[] buf, int offset,
1981 private int Send_internal(GHSocket sock,
1982 byte[] buf, int offset,
1987 return sock.Send_internal(buf, offset, count, flags, out error);
1991 public int Send (byte[] buf, int offset, int size, SocketFlags flags)
1993 EnsureStillUsable();
1996 throw new ArgumentNullException ("buffer");
1998 if (offset < 0 || offset > buf.Length)
1999 throw new ArgumentOutOfRangeException ("offset");
2001 if (size < 0 || offset + size > buf.Length)
2002 throw new ArgumentOutOfRangeException ("size");
2004 return Send_nochecks (buf, offset, size, flags);
2007 int Send_nochecks (byte [] buf, int offset, int size, SocketFlags flags)
2014 ret = Send_internal (socket, buf, offset, size, flags, out error);
2017 if (error != 10035 && error != 10036) // WSAEWOULDBLOCK && WSAEINPROGRESS
2020 throw new SocketException (error);
2027 public int SendTo (byte [] buffer, EndPoint remote_end)
2029 EnsureStillUsable();
2032 throw new ArgumentNullException ("buffer");
2034 if (remote_end == null)
2035 throw new ArgumentNullException ("remote_end");
2037 return SendTo_nochecks (buffer, 0, buffer.Length, SocketFlags.None, remote_end);
2040 public int SendTo (byte [] buffer, SocketFlags flags, EndPoint remote_end)
2042 EnsureStillUsable();
2045 throw new ArgumentNullException ("buffer");
2047 if (remote_end == null)
2048 throw new ArgumentNullException ("remote_end");
2050 return SendTo_nochecks (buffer, 0, buffer.Length, flags, remote_end);
2053 public int SendTo (byte [] buffer, int size, SocketFlags flags, EndPoint remote_end)
2055 EnsureStillUsable();
2058 throw new ArgumentNullException ("buffer");
2060 if (remote_end == null)
2061 throw new ArgumentNullException ("remote_end");
2063 if (size < 0 || size > buffer.Length)
2064 throw new ArgumentOutOfRangeException ("size");
2066 return SendTo_nochecks (buffer, 0, size, flags, remote_end);
2070 [MethodImplAttribute(MethodImplOptions.InternalCall)]
2071 private extern static int SendTo_internal(IntPtr sock,
2079 private int SendTo_internal(GHSocket sock,
2087 return sock.SendTo_internal(buffer, offset, count, flags, sa, out error);
2091 public int SendTo(byte[] buffer, int offset, int size, SocketFlags flags,
2092 EndPoint remote_end)
2094 EnsureStillUsable();
2097 throw new ArgumentNullException ("buffer");
2099 if (remote_end == null)
2100 throw new ArgumentNullException("remote_end");
2102 if (offset < 0 || offset > buffer.Length)
2103 throw new ArgumentOutOfRangeException ("offset");
2105 if (size < 0 || offset + size > buffer.Length)
2106 throw new ArgumentOutOfRangeException ("size");
2108 return SendTo_nochecks (buffer, offset, size, flags, remote_end);
2111 int SendTo_nochecks (byte [] buffer, int offset, int size, SocketFlags flags,
2112 EndPoint remote_end)
2114 SocketAddress sockaddr=remote_end.Serialize();
2118 ret = SendTo_internal (socket, buffer, offset, size, flags, sockaddr, out error);
2121 if (error != 10035 && error != 10036) // WSAEWOULDBLOCK && WSAEINPROGRESS
2124 throw new SocketException (error);
2133 [MethodImplAttribute(MethodImplOptions.InternalCall)]
2134 private extern static void SetSocketOption_internal (IntPtr socket, SocketOptionLevel level,
2135 SocketOptionName name, object obj_val,
2136 byte [] byte_val, int int_val,
2139 private void SetSocketOption_internal (GHSocket socket, SocketOptionLevel level,
2140 SocketOptionName name, object obj_val,
2141 byte [] byte_val, int int_val,
2144 socket.SetSocketOption_internal(level, name, obj_val, byte_val, int_val, out error);
2148 public void SetSocketOption (SocketOptionLevel level, SocketOptionName name, byte[] opt_value)
2150 EnsureStillUsable();
2154 SetSocketOption_internal(socket, level, name, null,
2155 opt_value, 0, out error);
2158 throw new SocketException (error);
2162 public void SetSocketOption (SocketOptionLevel level, SocketOptionName name, int opt_value)
2164 EnsureStillUsable();
2168 SetSocketOption_internal(socket, level, name, null,
2169 null, opt_value, out error);
2172 throw new SocketException (error);
2176 public void SetSocketOption (SocketOptionLevel level, SocketOptionName name, object opt_value)
2179 EnsureStillUsable();
2181 if(opt_value==null) {
2182 throw new ArgumentNullException();
2186 /* From MS documentation on SetSocketOption: "For an
2187 * option with a Boolean data type, specify a nonzero
2188 * value to enable the option, and a zero value to
2189 * disable the option."
2190 * Booleans are only handled in 2.0
2193 if (opt_value is System.Boolean) {
2194 bool bool_val = (bool) opt_value;
2195 int int_val = (bool_val) ? 1 : 0;
2197 SetSocketOption_internal (socket, level, name, null, null, int_val, out error);
2199 SetSocketOption_internal (socket, level, name, opt_value, null, 0, out error);
2203 throw new SocketException (error);
2206 public void SetSocketOption (SocketOptionLevel level, SocketOptionName name, bool optionValue) {
2207 EnsureStillUsable();
2210 int int_val = (optionValue) ? 1 : 0;
2211 SetSocketOption_internal (socket, level, name, null, null, int_val, out error);
2213 throw new SocketException (error);
2217 [MethodImplAttribute(MethodImplOptions.InternalCall)]
2218 private extern static void Shutdown_internal(IntPtr socket, SocketShutdown how, out int error);
2220 private void Shutdown_internal(GHSocket socket, SocketShutdown how, out int error)
2222 socket.Shutdown_internal(how, out error);
2226 public void Shutdown(SocketShutdown how)
2228 EnsureStillUsable();
2232 Shutdown_internal(socket, how, out error);
2235 throw new SocketException (error);
2240 public override int GetHashCode ()
2242 return (int) socket;
2245 public override int GetHashCode ()
2250 return socket.GetHashCode();
2255 protected virtual void Dispose (bool explicitDisposing)
2262 if ((int) socket != -1)
2267 socket = (IntPtr) (-1);
2268 Close_internal (x, out error);
2269 if (blocking_thread != null)
2271 blocking_thread.Abort ();
2272 blocking_thread = null;
2276 throw new SocketException (error);
2280 private void EnsureStillUsable()
2282 if (disposed && closed)
2283 throw new ObjectDisposedException(this.GetType().ToString());
2285 protected virtual void Dispose (bool explicitDisposing)
2296 GHSocket x = socket;
2298 Close_internal (x, out error);
2301 throw new SocketException (error);
2306 #region .Net 2.0 properties and methods
2310 public int ReceiveBufferSize
2312 get { throw new NotImplementedException(); }
2313 set { throw new NotImplementedException(); }
2317 public int SendBufferSize
2319 get { throw new NotImplementedException(); }
2320 set { throw new NotImplementedException(); }
2324 public bool UseOnlyOverlappedIO
2326 get { throw new NotImplementedException(); }
2327 set { throw new NotImplementedException(); }
2333 get { throw new NotImplementedException(); }
2334 set { throw new NotImplementedException(); }
2340 get { throw new NotImplementedException(); }
2344 public bool ExclusiveAddressUse
2346 get { throw new NotImplementedException(); }
2347 set { throw new NotImplementedException(); }
2350 [MonoTODO("udp sockets are not supported")]
2351 public bool DontFragment
2353 get { throw new NotImplementedException(); }
2354 set { throw new NotImplementedException(); }
2358 public bool EnableBroadcast
2360 get { throw new NotImplementedException(); }
2361 set { throw new NotImplementedException(); }
2365 public bool MulticastLoopback
2367 get { throw new NotImplementedException(); }
2368 set { throw new NotImplementedException(); }
2374 get { throw new NotImplementedException(); }
2375 set { throw new NotImplementedException(); }
2379 public int ReceiveTimeout
2381 get { throw new NotImplementedException(); }
2382 set { throw new NotImplementedException(); }
2386 public int SendTimeout
2388 get { throw new NotImplementedException(); }
2389 set { throw new NotImplementedException(); }
2392 #endregion //Properties
2397 public IAsyncResult BeginConnect(IPAddress address, int port,
2398 AsyncCallback requestCallback,
2401 throw new NotImplementedException();
2405 public IAsyncResult BeginConnect(IPAddress[] addresses, int port,
2406 AsyncCallback requestCallback,
2409 throw new NotImplementedException();
2413 public IAsyncResult BeginConnect(string host, int port,
2414 AsyncCallback requestCallback,
2417 throw new NotImplementedException();
2421 public IAsyncResult BeginAccept(int receiveSize, AsyncCallback callback, object state)
2423 throw new NotImplementedException();
2427 public IAsyncResult BeginAccept( Socket acceptSocket,int receiveSize,
2428 AsyncCallback callback, object state)
2430 throw new NotImplementedException();
2433 [MonoNotSupported ("")]
2434 public Socket EndAccept (out byte [] buffer, IAsyncResult asyncResult)
2436 throw new NotImplementedException ();
2439 [MonoNotSupported ("")]
2440 public Socket EndAccept (out byte [] buffer, out int bytesTransferred, IAsyncResult asyncResult)
2442 throw new NotImplementedException ();
2446 public IAsyncResult BeginDisconnect(bool reuseSocket, AsyncCallback callback, object state)
2448 throw new NotImplementedException();
2451 [MonoNotSupported ("")]
2452 public IAsyncResult BeginSend (IList<ArraySegment<byte>> buffers, SocketFlags socketFlags, AsyncCallback callback, object state)
2454 throw new NotImplementedException ();
2457 [MonoNotSupported ("")]
2458 [CLSCompliantAttribute (false)]
2459 public IAsyncResult BeginSend (IList<ArraySegment<byte>> buffers, SocketFlags socketFlags,
2460 out SocketError errorCode, AsyncCallback callback,
2463 throw new NotImplementedException ();
2467 public IAsyncResult BeginSend(byte[] buffer, int offset, int size,
2468 SocketFlags socketFlags, out SocketError errorCode,
2469 AsyncCallback callback, object state)
2471 throw new NotImplementedException();
2474 [MonoNotSupported ("")]
2475 public int EndSend (IAsyncResult asyncResult, out SocketError errorCode)
2477 throw new NotImplementedException ();
2480 [MonoNotSupported ("")]
2481 public IAsyncResult BeginReceive (byte [] buffer, int offset, int size, SocketFlags socketFlags, out SocketError errorCode, AsyncCallback callback, Object state)
2483 throw new NotImplementedException ();
2486 [CLSCompliantAttribute (false)]
2487 [MonoNotSupported ("")]
2488 public IAsyncResult BeginReceive (IList<ArraySegment<byte>> buffers, SocketFlags socketFlags, AsyncCallback callback, Object state)
2490 throw new NotImplementedException ();
2493 [CLSCompliantAttribute (false)]
2494 [MonoNotSupported ("")]
2495 public IAsyncResult BeginReceive (IList<ArraySegment<byte>> buffers, SocketFlags socketFlags, out SocketError errorCode, AsyncCallback callback, Object state)
2497 throw new NotImplementedException ();
2500 [MonoNotSupported ("")]
2501 public int EndReceive (IAsyncResult asyncResult, out SocketError errorCode)
2503 throw new NotImplementedException ();
2506 [MonoNotSupported ("")]
2507 public void SendFile (string fileName)
2509 throw new NotImplementedException ();
2512 [MonoNotSupported ("")]
2513 public void SendFile (string fileName, byte [] preBuffer, byte [] postBuffer, TransmitFileOptions flags)
2515 throw new NotImplementedException ();
2518 [MonoNotSupported ("")]
2519 public IAsyncResult BeginSendFile (string fileName, AsyncCallback callback, object state)
2521 throw new NotImplementedException ();
2524 [MonoNotSupported ("")]
2525 public IAsyncResult BeginSendFile (string fileName, byte [] preBuffer, byte [] postBuffer, TransmitFileOptions flags, AsyncCallback callback, object state)
2527 throw new NotImplementedException ();
2530 [MonoNotSupported ("")]
2531 public void EndSendFile (IAsyncResult asyncResult)
2533 throw new NotImplementedException ();
2537 public void Close(int timeout)
2539 throw new NotImplementedException();
2543 public void Connect(IPAddress address, int port)
2545 throw new NotImplementedException();
2549 public void Connect(IPAddress[] address, int port)
2551 throw new NotImplementedException();
2555 public void Connect(string host, int port)
2557 throw new NotImplementedException();
2560 [MonoNotSupported ("")]
2561 public void Disconnect (bool reuseSocket)
2563 throw new NotImplementedException ();
2566 [MonoNotSupported ("")]
2567 public SocketInformation DuplicateAndClose (int targetProcessId)
2569 throw new NotImplementedException ();
2571 #endregion //Methods
2575 void IDisposable.Dispose ()
2578 GC.SuppressFinalize (this);