diff options
Diffstat (limited to 'mcs/class/System/System.Net.Sockets')
18 files changed, 0 insertions, 2853 deletions
diff --git a/mcs/class/System/System.Net.Sockets/AddressFamily.cs b/mcs/class/System/System.Net.Sockets/AddressFamily.cs deleted file mode 100644 index c53fd8835b1..00000000000 --- a/mcs/class/System/System.Net.Sockets/AddressFamily.cs +++ /dev/null @@ -1,50 +0,0 @@ -// AddressFamily.cs -// -// This code was automatically generated from -// ECMA CLI XML Library Specification. -// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)] -// Created: Wed, 5 Sep 2001 06:31:59 UTC -// Source file: AllTypes.xml -// URL: http://msdn.microsoft.com/net/ecma/AllTypes.xml -// -// (C) 2001 Ximian, Inc. http://www.ximian.com - - -namespace System.Net.Sockets { - - - [Serializable] - public enum AddressFamily { - Unknown = -1, - Unspecified = 0, - Unix = 1, - InterNetwork = 2, - ImpLink = 3, - Pup = 4, - Chaos = 5, - NS = 6, - Ipx = 6, - Iso = 7, - Osi = 7, - Ecma = 8, - DataKit = 9, - Ccitt = 10, - Sna = 11, - DecNet = 12, - DataLink = 13, - Lat = 14, - HyperChannel = 15, - AppleTalk = 16, - NetBios = 17, - VoiceView = 18, - FireFox = 19, - Banyan = 21, - Atm = 22, - InterNetworkV6 = 23, - Cluster = 24, - Ieee12844 = 25, - Irda = 26, - NetworkDesigners = 28, - Max = 29, - } -} diff --git a/mcs/class/System/System.Net.Sockets/ChangeLog b/mcs/class/System/System.Net.Sockets/ChangeLog deleted file mode 100644 index 82c2103ea72..00000000000 --- a/mcs/class/System/System.Net.Sockets/ChangeLog +++ /dev/null @@ -1,86 +0,0 @@ -2002-10-08 Dick Porter <dick@ximian.com> - - * Socket.cs: - * NetworkStream.cs: Bounds checking fixes, and better exception - texts. Changes by timothyjmills@hotmail.com (Timothy J. Mills). - -2002-10-03 Dick Porter <dick@ximian.com> - - * TcpClient.cs: NoDelay is a TCP option, not Socket - -2002-09-16 Miguel de Icaza <miguel@ximian.com> - - * SocketFlags.cs: Add missing enumeration. - - * UdpClient.cs: Make Dispose private. - -2002-08-20 Dick Porter <dick@ximian.com> - - * Socket.cs: Fix deadlock when the AsyncResult callback calls - End*(). Set the async request's worker property so it can return - results. These two fixes combined fix bug 28092. - -2002-06-24 Dick Porter <dick@ximian.com> - - * Socket.cs: Make SetSocketOption cope with boolean values (they - are passed as objects, not the ints the runtime was expecting) - -2002-05-17 Lawrence Pit <loz@cable.a2000.nl> - * TcpListener.cs: Renamed LocalEndPoint to LocalEndpoint - * NetworkStream.cs, UdpClient.cs and TcpClient.cs: modified disposable - routines, added checks for disposed state. - * UdpClient.cs: commented out GetHashCode and Equals as it's not - overriden in ms.net implementation. - -2002-05-17 Jaroslaw Kowalski <jarek@atm.com.pl> - * TcpClient.cs: fixed SetTcpClient so that - TcpListener.AcceptTcpClient works and allows - you to call GetStream() on its result - -2002-04-24 Dick Porter <dick@ximian.com> - - * Socket.cs (Poll): Give correct argument to Select(), as spotted - by Jaroslaw Kowalski <jarek@atm.com.pl> - -2002-04-16 Gonzalo Paniagua Javier <gonzalo@ximian.com> - - * UdpClient.cs: implemented. - -2002-04-02 Dick Porter <dick@ximian.com> - - * TcpListener.cs: in Start(), set the socket listen backlog value - to a sane value (noticed by Jonathan Stowe <gellyfish@gellyfish.com>) - -2002-02-13 Dick Porter <dick@ximian.com> - - * Socket.cs: Implemenent Select, Blocking, Connected, - GetSocketOption, Poll, SetSocketOption and Shutdown - - * MulticastOption.cs: - * LingerOption.cs: Delete override methods that don't need to be - implemented - -2002-01-23 Miguel de Icaza <miguel@ximian.com> - - * NetworkStream.cs: Implement class. - -2002-01-23 Dick Porter <dick@ximian.com> - - * SocketException.cs: Implemented - - * Socket.cs: Implemented most methods - - * LingerOption.cs: Made compile - - * AddressFamily.cs: Removed empty auto-generated comments - -2002-01-17 Miguel de Icaza <miguel@ximian.com> - - * SocketException.cs: Reimplemented. - -2002-01-06 Ravi Pratap <ravi@ximian.com> - - * ChangeLog : Add to this directory. - - * SocketException.cs, TcpClient.cs, TcpListener.cs : MonoTODO - attribute decoration. diff --git a/mcs/class/System/System.Net.Sockets/LingerOption.cs b/mcs/class/System/System.Net.Sockets/LingerOption.cs deleted file mode 100644 index 4c6117f5035..00000000000 --- a/mcs/class/System/System.Net.Sockets/LingerOption.cs +++ /dev/null @@ -1,42 +0,0 @@ -// -// System.Net.Sockets.LingerOption.cs -// -// Author: -// Andrew Sutton -// -// (C) Andrew Sutton -// - -using System; - -namespace System.Net.Sockets -{ - // <remarks> - // Encapsulates a linger option. - // </remarks> - public class LingerOption - { - // Don't change the names of these fields without also - // changing socket-io.c in the runtime - private bool enabled; - protected int seconds; - - public LingerOption (bool enable, int secs) - { - enabled = enable; - seconds = secs; - } - - public bool Enabled - { - get { return enabled; } - set { enabled = value; } - } - - public int LingerTime - { - get { return seconds; } - set { seconds = value; } - } - } -} diff --git a/mcs/class/System/System.Net.Sockets/MulticastOption.cs b/mcs/class/System/System.Net.Sockets/MulticastOption.cs deleted file mode 100644 index 759cd48f314..00000000000 --- a/mcs/class/System/System.Net.Sockets/MulticastOption.cs +++ /dev/null @@ -1,48 +0,0 @@ -// -// System.Net.Sockets.MulticastOption.cs -// -// Author: -// Andrew Sutton -// -// (C) Andrew Sutton -// - -using System; -using System.Net; - -namespace System.Net.Sockets -{ - // <remarks> - // Encapsulates a multicast option - // </remarks> - public class MulticastOption - { - // Don't change the names of these fields without also - // changing socket-io.c in the runtime - private IPAddress group; - protected IPAddress local; - - public MulticastOption (IPAddress grp) - { - group = grp; - } - - public MulticastOption (IPAddress grp, IPAddress addr) - { - group = grp; - local = addr; - } - - public IPAddress Group - { - get { return group; } - set { group = value; } - } - - public IPAddress LocalAddress - { - get { return local; } - set { local = value; } - } - } -} diff --git a/mcs/class/System/System.Net.Sockets/NetworkStream.cs b/mcs/class/System/System.Net.Sockets/NetworkStream.cs deleted file mode 100644 index ea74bb6e254..00000000000 --- a/mcs/class/System/System.Net.Sockets/NetworkStream.cs +++ /dev/null @@ -1,324 +0,0 @@ -// -// System.Net.Sockets.NetworkStream.cs -// -// Author: -// Miguel de Icaza (miguel@ximian.com) -// -// (C) 2002 Ximian, Inc. http://www.ximian.com -// - -using System.IO; - -namespace System.Net.Sockets -{ - public class NetworkStream : Stream, IDisposable { - FileAccess access; - Socket socket; - bool owns_socket; - bool readable, writeable; - bool disposed = false; - - public NetworkStream (Socket socket) - : this (socket, FileAccess.ReadWrite, false) - { - } - - public NetworkStream (Socket socket, bool owns_socket) - : this (socket, FileAccess.ReadWrite, owns_socket) - { - } - - public NetworkStream (Socket socket, FileAccess access) - : this (socket, access, false) - { - } - - public NetworkStream (Socket socket, FileAccess access, bool owns_socket) - { - if (socket == null) - throw new ArgumentNullException ("socket is null"); - if (!socket.Connected) - throw new ArgumentException ("Not connected", "socket"); - if (socket.SocketType != SocketType.Stream) - throw new ArgumentException ("Socket is not of type Stream", "socket"); - if (!socket.Blocking) - throw new IOException (); - - this.socket = socket; - this.owns_socket = owns_socket; - this.access = access; - - readable = CanRead; - writeable = CanWrite; - } - - public override bool CanRead { - get { - return access == FileAccess.ReadWrite || access == FileAccess.Read; - } - } - - public override bool CanSeek { - get { - // network sockets cant seek. - return false; - } - } - - public override bool CanWrite { - get { - return access == FileAccess.ReadWrite || access == FileAccess.Write; - } - } - - public virtual bool DataAvailable { - get { - try { - return socket.Available > 0; - } finally { - CheckDisposed (); - } - } - } - - public override long Length { - get { - // Network sockets always throw an exception - throw new NotSupportedException (); - } - } - - public override long Position { - get { - // Network sockets always throw an exception - throw new NotSupportedException (); - } - - set { - // Network sockets always throw an exception - throw new NotSupportedException (); - } - } - - protected bool Readable { - get { - return readable; - } - - set { - readable = value; - } - } - - protected Socket Socket { - get { - return socket; - } - } - - protected bool Writeable { - get { - return writeable; - } - - set { - writeable = value; - } - } - - public override IAsyncResult BeginRead (byte [] buffer, int offset, int size, - AsyncCallback callback, object state) - { - try { - IAsyncResult retval; - - if (buffer == null) - throw new ArgumentNullException ("buffer is null"); - int len = buffer.Length; - if(offset<0 || offset>=len) { - throw new ArgumentOutOfRangeException("offset exceeds the size of buffer"); - } - if(offset+size<0 || offset+size>len) { - throw new ArgumentOutOfRangeException("offset+size exceeds the size of buffer"); - } - - try { - retval = socket.BeginReceive (buffer, offset, size, 0, callback, state); - } catch { - throw new IOException ("BeginReceive failure"); - } - - return retval; - } finally { - CheckDisposed (); - } - } - - public override IAsyncResult BeginWrite (byte [] buffer, int offset, int size, - AsyncCallback callback, object state) - { - try { - IAsyncResult retval; - - if (buffer == null) - throw new ArgumentNullException ("buffer is null"); - - int len = buffer.Length; - if(offset<0 || offset>=len) { - throw new ArgumentOutOfRangeException("offset exceeds the size of buffer"); - } - if(offset+size<0 || offset+size>len) { - throw new ArgumentOutOfRangeException("offset+size exceeds the size of buffer"); - } - - try { - retval = socket.BeginSend (buffer, offset, size, 0, callback, state); - } catch { - throw new IOException ("BeginWrite failure"); - } - - return retval; - } finally { - CheckDisposed (); - } - } - - ~NetworkStream () - { - Dispose (false); - } - - public override void Close () - { - ((IDisposable) this).Dispose (); - } - - protected virtual void Dispose (bool disposing) - { - if (disposed) - return; - disposed = true; - - if (owns_socket) { - Socket s = socket; - if (s != null) - s.Close (); - } - socket = null; - } - - public override int EndRead (IAsyncResult ar) - { - try { - int res; - - if (ar == null) - throw new ArgumentNullException ("async result is null"); - - try { - res = socket.EndReceive (ar); - } catch { - throw new IOException ("EndRead failure"); - } - return res; - } finally { - CheckDisposed (); - } - } - - public override void EndWrite (IAsyncResult ar) - { - try { - if (ar == null) - throw new ArgumentNullException ("async result is null"); - - try { - socket.EndSend (ar); - } catch { - throw new IOException ("EndWrite failure"); - } - } finally { - CheckDisposed (); - } - } - - public override void Flush () - { - // network streams are non-buffered, this is a no-op - } - - void IDisposable.Dispose () - { - Dispose (true); - GC.SuppressFinalize (this); - } - - public override int Read (byte [] buffer, int offset, int size) - { - try { - int res; - - if (buffer == null) - throw new ArgumentNullException ("buffer is null"); - if(offset<0 || offset>=buffer.Length) { - throw new ArgumentOutOfRangeException("offset exceeds the size of buffer"); - } - if(offset+size < 0 || offset+size>buffer.Length) { - throw new ArgumentOutOfRangeException("offset+size exceeds the size of buffer"); - } - - try { - res = socket.Receive (buffer, offset, size, 0); - } catch { - throw new IOException ("Read failure"); - } - return res; - } finally { - CheckDisposed (); - } - } - - public override long Seek (long offset, SeekOrigin origin) - { - // NetworkStream objects do not support seeking. - - throw new NotSupportedException (); - } - - public override void SetLength (long value) - { - // NetworkStream objects do not support SetLength - - throw new NotSupportedException (); - } - - public override void Write (byte [] buffer, int offset, int size) - { - try { - if (buffer == null) - throw new ArgumentNullException ("buffer is null"); - if(offset<0 || offset>=buffer.Length) { - throw new ArgumentOutOfRangeException("offset exceeds the size of buffer"); - } - if(offset+size<0 || offset+size>buffer.Length) { - throw new ArgumentOutOfRangeException("offset+size exceeds the size of buffer"); - } - - try { - socket.Send (buffer, offset, size, 0); - } catch { - throw new IOException ("Write failure"); - } - } finally { - CheckDisposed (); - } - } - - private void CheckDisposed () - { - if (disposed) - throw new ObjectDisposedException (GetType().FullName); - } - - } -} diff --git a/mcs/class/System/System.Net.Sockets/ProtocolFamily.cs b/mcs/class/System/System.Net.Sockets/ProtocolFamily.cs deleted file mode 100644 index cf6d59acfc2..00000000000 --- a/mcs/class/System/System.Net.Sockets/ProtocolFamily.cs +++ /dev/null @@ -1,47 +0,0 @@ -// -// System.Net.Sockets.ProtocolFamily.cs -// -// Author: -// Andrew Sutton -// -// (C) Andrew Sutton -// - -namespace System.Net.Sockets -{ - public enum ProtocolFamily - { - Unknown = -1, - Unspecified = 0, - Unix, - InterNetwork, - ImpLink, - Pup, - Chaos, - Ipx, - Iso, - Ecma, - DataKit, - Ccitt, - Sna, - DecNet, - DataLink, - Lat, - HyperChannel, - AppleTalk, - NetBios, - VoiceView, - FireFox, - Banyan = 0x15, - Atm, - InterNetworkV6, - Cluster, - Ieee12844, - Irda, - NetworkDesigners = 0x1c, - Max, - - NS = Ipx, - Osi = Iso, - } -} diff --git a/mcs/class/System/System.Net.Sockets/ProtocolType.cs b/mcs/class/System/System.Net.Sockets/ProtocolType.cs deleted file mode 100644 index 0b106e5f946..00000000000 --- a/mcs/class/System/System.Net.Sockets/ProtocolType.cs +++ /dev/null @@ -1,81 +0,0 @@ -// ProtocolType.cs -// -// This code was automatically generated from -// ECMA CLI XML Library Specification. -// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)] -// Created: Wed, 5 Sep 2001 06:32:24 UTC -// Source file: AllTypes.xml -// URL: http://msdn.microsoft.com/net/ecma/AllTypes.xml -// -// (C) 2001 Ximian, Inc. http://www.ximian.com - - -namespace System.Net.Sockets { - - - /// <summary> - /// </summary> - public enum ProtocolType { - - /// <summary> - /// </summary> - IP = 0, - - /// <summary> - /// </summary> - Icmp = 1, - - /// <summary> - /// </summary> - Igmp = 2, - - /// <summary> - /// </summary> - Ggp = 3, - - /// <summary> - /// </summary> - Tcp = 6, - - /// <summary> - /// </summary> - Pup = 12, - - /// <summary> - /// </summary> - Udp = 17, - - /// <summary> - /// </summary> - Idp = 22, - - /// <summary> - /// </summary> - ND = 77, - - /// <summary> - /// </summary> - Raw = 255, - - /// <summary> - /// </summary> - Unspecified = 0, - - /// <summary> - /// </summary> - Ipx = 1000, - - /// <summary> - /// </summary> - Spx = 1256, - - /// <summary> - /// </summary> - SpxII = 1257, - - /// <summary> - /// </summary> - Unknown = -1, - } // ProtocolType - -} // System.Net.Sockets diff --git a/mcs/class/System/System.Net.Sockets/SelectMode.cs b/mcs/class/System/System.Net.Sockets/SelectMode.cs deleted file mode 100644 index 587f2a1d1b6..00000000000 --- a/mcs/class/System/System.Net.Sockets/SelectMode.cs +++ /dev/null @@ -1,33 +0,0 @@ -// SelectMode.cs -// -// This code was automatically generated from -// ECMA CLI XML Library Specification. -// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)] -// Created: Wed, 5 Sep 2001 06:32:30 UTC -// Source file: AllTypes.xml -// URL: http://msdn.microsoft.com/net/ecma/AllTypes.xml -// -// (C) 2001 Ximian, Inc. http://www.ximian.com - - -namespace System.Net.Sockets { - - - /// <summary> - /// </summary> - public enum SelectMode { - - /// <summary> - /// </summary> - SelectRead = 0, - - /// <summary> - /// </summary> - SelectWrite = 1, - - /// <summary> - /// </summary> - SelectError = 2, - } // SelectMode - -} // System.Net.Sockets diff --git a/mcs/class/System/System.Net.Sockets/Socket.cs b/mcs/class/System/System.Net.Sockets/Socket.cs deleted file mode 100644 index a9ebb84021e..00000000000 --- a/mcs/class/System/System.Net.Sockets/Socket.cs +++ /dev/null @@ -1,981 +0,0 @@ -// System.Net.Sockets.Socket.cs -// -// Authors: -// Phillip Pearson (pp@myelin.co.nz) -// Dick Porter <dick@ximian.com> -// -// Copyright (C) 2001, 2002 Phillip Pearson and Ximian, Inc. -// http://www.myelin.co.nz -// - -using System; -using System.Net; -using System.Collections; -using System.Runtime.CompilerServices; -using System.Threading; - -namespace System.Net.Sockets -{ - public class Socket : IDisposable - { - private sealed class SocketAsyncResult: IAsyncResult - { - private object state; - private WaitHandle waithandle; - private bool completed_sync, completed; - private Worker worker; - - public SocketAsyncResult(object state) { - this.state=state; - waithandle=new ManualResetEvent(false); - completed_sync=completed=false; - } - - public object AsyncState { - get { - return(state); - } - } - - public WaitHandle AsyncWaitHandle { - get { - return(waithandle); - } - set { - waithandle=value; - } - } - - public bool CompletedSynchronously { - get { - return(completed_sync); - } - } - - public bool IsCompleted { - get { - return(completed); - } - set { - completed=value; - } - } - - public Worker Worker { - get { - return(worker); - } - set { - worker=value; - } - } - } - - private sealed class Worker - { - private AsyncCallback callback; - private SocketAsyncResult result; - private Socket socket; - - // Parameters - private EndPoint endpoint; // Connect,ReceiveFrom,SendTo - private byte[] buffer; // Receive,ReceiveFrom,Send,SendTo - private int offset; // Receive,ReceiveFrom,Send,SendTo - private int size; // Receive,ReceiveFrom,Send,SendTo - private SocketFlags sockflags; // Receive,ReceiveFrom,Send,SendTo - - // Return values - private Socket acc_socket; - private int total; - - - // For Accept - public Worker(Socket req_sock, - AsyncCallback req_callback, - SocketAsyncResult req_result) - : this(req_sock, null, 0, 0, SocketFlags.None, - null, req_callback, req_result) {} - - // For Connect - public Worker(Socket req_sock, EndPoint req_endpoint, - AsyncCallback req_callback, - SocketAsyncResult req_result) - : this(req_sock, null, 0, 0, SocketFlags.None, - req_endpoint, req_callback, - req_result) {} - - // For Receive and Send - public Worker(Socket req_sock, byte[] req_buffer, - int req_offset, int req_size, - SocketFlags req_sockflags, - AsyncCallback req_callback, - SocketAsyncResult req_result) - : this(req_sock, req_buffer, req_offset, - req_size, req_sockflags, null, - req_callback, req_result) {} - - // For ReceiveFrom and SendTo - public Worker(Socket req_sock, byte[] req_buffer, - int req_offset, int req_size, - SocketFlags req_sockflags, - EndPoint req_endpoint, - AsyncCallback req_callback, - SocketAsyncResult req_result) { - socket=req_sock; - buffer=req_buffer; - offset=req_offset; - size=req_size; - sockflags=req_sockflags; - endpoint=req_endpoint; - callback=req_callback; - result=req_result; - } - - private void End() { - ((ManualResetEvent)result.AsyncWaitHandle).Set(); - callback(result); - result.IsCompleted=true; - } - - public void Accept() { - lock(result) { - acc_socket=socket.Accept(); - End(); - } - } - - public void Connect() { - lock(result) { - socket.Connect(endpoint); - End(); - } - } - - public void Receive() { - lock(result) { - total=socket.Receive(buffer, offset, - size, sockflags); - End(); - } - } - - public void ReceiveFrom() { - lock(result) { - total=socket.ReceiveFrom(buffer, - offset, size, - sockflags, - ref endpoint); - End(); - } - } - - public void Send() { - lock(result) { - total=socket.Send(buffer, offset, size, - sockflags); - End(); - } - } - - public void SendTo() { - lock(result) { - total=socket.SendTo(buffer, offset, - size, sockflags, - endpoint); - End(); - } - } - - public EndPoint EndPoint { - get { - return(endpoint); - } - } - - public Socket Socket { - get { - return(acc_socket); - } - } - - public int Total { - get { - return(total); - } - } - } - - /* the field "socket" is looked up by name by the runtime */ - private IntPtr socket; - private AddressFamily address_family; - private SocketType socket_type; - private ProtocolType protocol_type; - private bool blocking=true; - - /* When true, the socket was connected at the time of - * the last IO operation - */ - private bool connected=false; - - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private extern static void Select_internal(ref Socket[] read, - ref Socket[] write, - ref Socket[] err, - int timeout); - - public static void Select(IList read_list, IList write_list, - IList err_list, int time_us) { - if(read_list==null && - write_list==null && - err_list==null) { - throw new ArgumentNullException(); - } - - int read_count, write_count, err_count; - - if(read_list!=null) { - read_count=read_list.Count; - } else { - read_count=0; - } - - if(write_list!=null) { - write_count=write_list.Count; - } else { - write_count=0; - } - - if(err_list!=null) { - err_count=err_list.Count; - } else { - err_count=0; - } - - Socket[] read_arr=new Socket[read_count]; - Socket[] write_arr=new Socket[write_count]; - Socket[] err_arr=new Socket[err_count]; - - int i; - - if(read_list!=null) { - i=0; - - foreach (Socket s in read_list) { - read_arr[i]=s; - i++; - } - } - - if(write_list!=null) { - i=0; - foreach (Socket s in write_list) { - write_arr[i]=s; - i++; - } - } - - if(err_list!=null) { - i=0; - foreach (Socket s in err_list) { - err_arr[i]=s; - i++; - } - } - - Select_internal(ref read_arr, ref write_arr, - ref err_arr, time_us); - - if(read_list!=null) { - read_list.Clear(); - for(i=0; i<read_arr.Length; i++) { - read_list.Add(read_arr[i]); - } - } - - if(write_list!=null) { - write_list.Clear(); - for(i=0; i<write_arr.Length; i++) { - write_list.Add(write_arr[i]); - } - } - - if(err_list!=null) { - err_list.Clear(); - for(i=0; i<err_arr.Length; i++) { - err_list.Add(err_arr[i]); - } - } - } - - // private constructor used by Accept, which already - // has a socket handle to use - private Socket(AddressFamily family, SocketType type, - ProtocolType proto, IntPtr sock) { - address_family=family; - socket_type=type; - protocol_type=proto; - - socket=sock; - connected=true; - } - - // Creates a new system socket, returning the handle - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private extern IntPtr Socket_internal(AddressFamily family, - SocketType type, - ProtocolType proto); - - public Socket(AddressFamily family, SocketType type, - ProtocolType proto) { - address_family=family; - socket_type=type; - protocol_type=proto; - - socket=Socket_internal(family, type, proto); - } - - public AddressFamily AddressFamily { - get { - return(address_family); - } - } - - // Returns the amount of data waiting to be read on socket - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private extern static int Available_internal(IntPtr socket); - - public int Available { - get { - return(Available_internal(socket)); - } - } - - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private extern static void Blocking_internal(IntPtr socket, - bool block); - - public bool Blocking { - get { - return(blocking); - } - set { - Blocking_internal(socket, value); - blocking=value; - } - } - - public bool Connected { - get { - return(connected); - } - } - - public IntPtr Handle { - get { - return(socket); - } - } - - // Returns the local endpoint details in addr and port - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private extern static SocketAddress LocalEndPoint_internal(IntPtr socket); - - [MonoTODO("Support non-IP endpoints")] - public EndPoint LocalEndPoint { - get { - SocketAddress sa; - - sa=LocalEndPoint_internal(socket); - - if(sa.Family==AddressFamily.InterNetwork) { - // Stupidly, EndPoint.Create() is an - // instance method - return new IPEndPoint(0, 0).Create(sa); - } else { - throw new NotImplementedException(); - } - } - } - - public ProtocolType ProtocolType { - get { - return(protocol_type); - } - } - - // Returns the remote endpoint details in addr and port - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private extern static SocketAddress RemoteEndPoint_internal(IntPtr socket); - - [MonoTODO("Support non-IP endpoints")] - public EndPoint RemoteEndPoint { - get { - SocketAddress sa; - - sa=RemoteEndPoint_internal(socket); - - if(sa.Family==AddressFamily.InterNetwork) { - // Stupidly, EndPoint.Create() is an - // instance method - return new IPEndPoint(0, 0).Create(sa); - } else { - throw new NotImplementedException(); - } - } - } - - public SocketType SocketType { - get { - return(socket_type); - } - } - - // Creates a new system socket, returning the handle - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private extern static IntPtr Accept_internal(IntPtr sock); - - public Socket Accept() { - IntPtr sock=Accept_internal(socket); - - return(new Socket(this.AddressFamily, this.SocketType, - this.ProtocolType, sock)); - } - - public IAsyncResult BeginAccept(AsyncCallback callback, - object state) { - SocketAsyncResult req=new SocketAsyncResult(state); - Worker worker=new Worker(this, callback, req); - req.Worker=worker; - Thread child=new Thread(new ThreadStart(worker.Accept)); - child.Start(); - return(req); - } - - public IAsyncResult BeginConnect(EndPoint end_point, - AsyncCallback callback, - object state) { - SocketAsyncResult req=new SocketAsyncResult(state); - Worker worker=new Worker(this, end_point, callback, - req); - req.Worker=worker; - Thread child=new Thread(new ThreadStart(worker.Connect)); - child.Start(); - return(req); - } - - public IAsyncResult BeginReceive(byte[] buffer, int offset, - int size, - SocketFlags socket_flags, - AsyncCallback callback, - object state) { - SocketAsyncResult req=new SocketAsyncResult(state); - Worker worker=new Worker(this, buffer, offset, size, - socket_flags, callback, req); - req.Worker=worker; - Thread child=new Thread(new ThreadStart(worker.Receive)); - child.Start(); - return(req); - } - - public IAsyncResult BeginReceiveFrom(byte[] buffer, int offset, - int size, - SocketFlags socket_flags, - ref EndPoint remote_end, - AsyncCallback callback, - object state) { - SocketAsyncResult req=new SocketAsyncResult(state); - Worker worker=new Worker(this, buffer, offset, size, - socket_flags, remote_end, - callback, req); - req.Worker=worker; - Thread child=new Thread(new ThreadStart(worker.ReceiveFrom)); - child.Start(); - return(req); - } - - public IAsyncResult BeginSend(byte[] buffer, int offset, - int size, - SocketFlags socket_flags, - AsyncCallback callback, - object state) { - SocketAsyncResult req=new SocketAsyncResult(state); - Worker worker=new Worker(this, buffer, offset, size, - socket_flags, callback, req); - req.Worker=worker; - Thread child=new Thread(new ThreadStart(worker.Send)); - child.Start(); - return(req); - } - - public IAsyncResult BeginSendTo(byte[] buffer, int offset, - int size, - SocketFlags socket_flags, - EndPoint remote_end, - AsyncCallback callback, - object state) { - SocketAsyncResult req=new SocketAsyncResult(state); - Worker worker=new Worker(this, buffer, offset, size, - socket_flags, remote_end, - callback, req); - req.Worker=worker; - Thread child=new Thread(new ThreadStart(worker.SendTo)); - child.Start(); - return(req); - } - - // Creates a new system socket, returning the handle - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private extern static void Bind_internal(IntPtr sock, - SocketAddress sa); - - public void Bind(EndPoint local_end) { - if(local_end==null) { - throw new ArgumentNullException(); - } - - Bind_internal(socket, local_end.Serialize()); - } - - // Closes the socket - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private extern static void Close_internal(IntPtr socket); - - public void Close() { - connected=false; - Close_internal(socket); - } - - // Connects to the remote address - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private extern static void Connect_internal(IntPtr sock, - SocketAddress sa); - - public void Connect(EndPoint remote_end) { - if(remote_end==null) { - throw new ArgumentNullException(); - } - - Connect_internal(socket, remote_end.Serialize()); - connected=true; - } - - public Socket EndAccept(IAsyncResult result) { - SocketAsyncResult req=(SocketAsyncResult)result; - - result.AsyncWaitHandle.WaitOne(); - return(req.Worker.Socket); - } - - public void EndConnect(IAsyncResult result) { - SocketAsyncResult req=(SocketAsyncResult)result; - - result.AsyncWaitHandle.WaitOne(); - } - - public int EndReceive(IAsyncResult result) { - SocketAsyncResult req=(SocketAsyncResult)result; - - result.AsyncWaitHandle.WaitOne(); - return(req.Worker.Total); - } - - public int EndReceiveFrom(IAsyncResult result, - ref EndPoint end_point) { - SocketAsyncResult req=(SocketAsyncResult)result; - - result.AsyncWaitHandle.WaitOne(); - end_point=req.Worker.EndPoint; - return(req.Worker.Total); - } - - public int EndSend(IAsyncResult result) { - SocketAsyncResult req=(SocketAsyncResult)result; - - result.AsyncWaitHandle.WaitOne(); - return(req.Worker.Total); - } - - public int EndSendTo(IAsyncResult result) { - SocketAsyncResult req=(SocketAsyncResult)result; - - result.AsyncWaitHandle.WaitOne(); - return(req.Worker.Total); - } - - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private extern static void GetSocketOption_obj_internal(IntPtr socket, SocketOptionLevel level, SocketOptionName name, out object obj_val); - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private extern static void GetSocketOption_arr_internal(IntPtr socket, SocketOptionLevel level, SocketOptionName name, ref byte[] byte_val); - - public object GetSocketOption(SocketOptionLevel level, - SocketOptionName name) { - object obj_val; - - GetSocketOption_obj_internal(socket, level, name, - out obj_val); - - if(name==SocketOptionName.Linger) { - return((LingerOption)obj_val); - } else if (name==SocketOptionName.AddMembership || - name==SocketOptionName.DropMembership) { - return((MulticastOption)obj_val); - } else { - return((int)obj_val); - } - } - - public void GetSocketOption(SocketOptionLevel level, - SocketOptionName name, - byte[] opt_value) { - int opt_value_len=opt_value.Length; - - GetSocketOption_arr_internal(socket, level, name, - ref opt_value); - } - - public byte[] GetSocketOption(SocketOptionLevel level, - SocketOptionName name, - int length) { - byte[] byte_val=new byte[length]; - - GetSocketOption_arr_internal(socket, level, name, - ref byte_val); - - return(byte_val); - } - - [MonoTODO("Totally undocumented")] - public int IOControl(int ioctl_code, byte[] in_value, - byte[] out_value) { - throw new NotImplementedException(); - } - - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private extern static void Listen_internal(IntPtr sock, - int backlog); - - public void Listen(int backlog) { - Listen_internal(socket, backlog); - } - - /* The docs for Poll() are a bit lightweight too, but - * it seems to be just a simple wrapper around Select. - */ - public bool Poll(int time_us, SelectMode mode) { - ArrayList socketlist=new ArrayList(1); - - socketlist.Add(this); - - switch(mode) { - case SelectMode.SelectError: - Select(null, null, socketlist, time_us); - break; - case SelectMode.SelectRead: - Select(socketlist, null, null, time_us); - break; - case SelectMode.SelectWrite: - Select(null, socketlist, null, time_us); - break; - default: - throw new NotSupportedException(); - } - - if(socketlist.Contains(this)) { - return(true); - } else { - return(false); - } - } - - public int Receive(byte[] buf) { - return(Receive(buf, 0, buf.Length, SocketFlags.None)); - } - - public int Receive(byte[] buf, SocketFlags flags) { - return(Receive(buf, 0, buf.Length, flags)); - } - - public int Receive(byte[] buf, int size, SocketFlags flags) { - return(Receive(buf, 0, size, flags)); - } - - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private extern static int Receive_internal(IntPtr sock, - byte[] buffer, - int offset, - int count, - SocketFlags flags); - - public int Receive(byte[] buf, int offset, int size, - SocketFlags flags) { - if(buf==null) { - throw new ArgumentNullException("buffer is null"); - } - if(offset<0 || offset >= buf.Length) { - throw new ArgumentOutOfRangeException("offset exceeds the size of buffer"); - } - if(offset+size<0 || offset+size > buf.Length) { - throw new ArgumentOutOfRangeException("offset+size exceeds the size of buffer"); - } - - int ret; - - try { - ret=Receive_internal(socket, buf, offset, - size, flags); - } catch(SocketException) { - connected=false; - throw; - } - connected=true; - - return(ret); - } - - public int ReceiveFrom(byte[] buf, ref EndPoint remote_end) { - return(ReceiveFrom(buf, 0, buf.Length, - SocketFlags.None, ref remote_end)); - } - - public int ReceiveFrom(byte[] buf, SocketFlags flags, - ref EndPoint remote_end) { - return(ReceiveFrom(buf, 0, buf.Length, flags, - ref remote_end)); - } - - public int ReceiveFrom(byte[] buf, int size, SocketFlags flags, - ref EndPoint remote_end) { - return(ReceiveFrom(buf, 0, size, flags, - ref remote_end)); - } - - - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private extern static int RecvFrom_internal(IntPtr sock, - byte[] buffer, - int offset, - int count, - SocketFlags flags, - ref SocketAddress sockaddr); - - public int ReceiveFrom(byte[] buf, int offset, int size, - SocketFlags flags, - ref EndPoint remote_end) { - if(buf==null) { - throw new ArgumentNullException("buffer is null"); - } - if(remote_end==null) { - throw new ArgumentNullException("remote endpoint is null"); - } - if(offset<0 || offset>=buf.Length) { - throw new ArgumentOutOfRangeException("offset exceeds the size of buffer"); - } - if(offset+size<0 || offset+size>buf.Length) { - throw new ArgumentOutOfRangeException("offset+size exceeds the size of buffer"); - } - - SocketAddress sockaddr=remote_end.Serialize(); - int count; - - try { - count=RecvFrom_internal(socket, buf, offset, - size, flags, - ref sockaddr); - } catch(SocketException) { - connected=false; - throw; - } - connected=true; - - // Stupidly, EndPoint.Create() is an - // instance method - remote_end=remote_end.Create(sockaddr); - - return(count); - } - - public int Send(byte[] buf) { - return(Send(buf, 0, buf.Length, SocketFlags.None)); - } - - public int Send(byte[] buf, SocketFlags flags) { - return(Send(buf, 0, buf.Length, flags)); - } - - public int Send(byte[] buf, int size, SocketFlags flags) { - return(Send(buf, 0, size, flags)); - } - - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private extern static int Send_internal(IntPtr sock, - byte[] buf, int offset, - int count, - SocketFlags flags); - - public int Send(byte[] buf, int offset, int size, - SocketFlags flags) { - if(buf==null) { - throw new ArgumentNullException("buffer is null"); - } - if(offset<0 || offset>=buf.Length) { - throw new ArgumentOutOfRangeException("offset exceeds the size of buffer"); - } - if(offset+size<0 || offset+size>buf.Length) { - throw new ArgumentOutOfRangeException("offset+size exceeds the size of buffer"); - } - - int ret; - - try { - ret=Send_internal(socket, buf, offset, size, - flags); - } catch(SocketException) { - connected=false; - throw; - } - connected=true; - - return(ret); - } - - public int SendTo(byte[] buffer, EndPoint remote_end) { - return(SendTo(buffer, 0, buffer.Length, - SocketFlags.None, remote_end)); - } - - public int SendTo(byte[] buffer, SocketFlags flags, - EndPoint remote_end) { - return(SendTo(buffer, 0, buffer.Length, flags, - remote_end)); - } - - public int SendTo(byte[] buffer, int size, SocketFlags flags, - EndPoint remote_end) { - return(SendTo(buffer, size, buffer.Length, flags, - remote_end)); - } - - - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private extern static int SendTo_internal(IntPtr sock, - byte[] buffer, - int offset, - int count, - SocketFlags flags, - SocketAddress sa); - - public int SendTo(byte[] buffer, int offset, int size, - SocketFlags flags, EndPoint remote_end) { - if(buffer==null) { - throw new ArgumentNullException("buffer is null"); - } - if(remote_end==null) { - throw new ArgumentNullException("remote endpoint is null"); - } - if(offset<0 || offset>=buffer.Length) { - throw new ArgumentOutOfRangeException("offset exceeds the size of buffer"); - } - if(offset+size<0 || offset+size>buffer.Length) { - throw new ArgumentOutOfRangeException("offset+size exceeds the size of buffer"); - } - - SocketAddress sockaddr=remote_end.Serialize(); - - int ret; - - try { - ret=SendTo_internal(socket, buffer, offset, - size, flags, sockaddr); - } - catch(SocketException) { - connected=false; - throw; - } - connected=true; - - return(ret); - } - - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private extern static void SetSocketOption_internal(IntPtr socket, SocketOptionLevel level, SocketOptionName name, object obj_val, byte[] byte_val, int int_val); - - public void SetSocketOption(SocketOptionLevel level, - SocketOptionName name, - byte[] opt_value) { - SetSocketOption_internal(socket, level, name, null, - opt_value, 0); - } - - public void SetSocketOption(SocketOptionLevel level, - SocketOptionName name, - int opt_value) { - SetSocketOption_internal(socket, level, name, null, - null, opt_value); - } - - public void SetSocketOption(SocketOptionLevel level, - SocketOptionName name, - object opt_value) { - if(opt_value==null) { - throw new ArgumentNullException(); - } - - /* Passing a bool as the third parameter to - * SetSocketOption causes this overload to be - * used when in fact we want to pass the value - * to the runtime as an int. - */ - if(opt_value is System.Boolean) { - bool bool_val=(bool)opt_value; - - /* Stupid casting rules :-( */ - if(bool_val==true) { - SetSocketOption_internal(socket, level, - name, null, - null, 1); - } else { - SetSocketOption_internal(socket, level, - name, null, - null, 0); - } - } else { - SetSocketOption_internal(socket, level, name, - opt_value, null, 0); - } - } - - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private extern static void Shutdown_internal(IntPtr socket, SocketShutdown how); - - public void Shutdown(SocketShutdown how) { - Shutdown_internal(socket, how); - } - - private bool disposed = false; - - protected virtual void Dispose(bool explicitDisposing) { - // Check to see if Dispose has already been called - if(!this.disposed) { - // If this is a call to Dispose, - // dispose all managed resources. - if(explicitDisposing) { - // Free up stuff here - } - - // Release unmanaged resources - this.disposed=true; - this.Close(); - } - } - - public void Dispose() { - Dispose(true); - // Take yourself off the Finalization queue - GC.SuppressFinalize(this); - } - - ~Socket () { - Dispose(false); - } - } -} diff --git a/mcs/class/System/System.Net.Sockets/SocketException.cs b/mcs/class/System/System.Net.Sockets/SocketException.cs deleted file mode 100644 index 161a7cf27ae..00000000000 --- a/mcs/class/System/System.Net.Sockets/SocketException.cs +++ /dev/null @@ -1,41 +0,0 @@ -// -// System.Net.Sockets.NetworkStream.cs -// -// Author: -// Dick Porter <dick@ximian.com> -// -// (C) 2002 Ximian, Inc. -// - -using System.Runtime.Serialization; -using System.ComponentModel; -using System.Runtime.CompilerServices; - -namespace System.Net.Sockets -{ - [Serializable] - public class SocketException : Win32Exception - { - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern int WSAGetLastError_internal(); - - public SocketException () - : base (WSAGetLastError_internal()) { - } - - public SocketException (int error) - : base (error) { - } - - protected SocketException (SerializationInfo info, - StreamingContext context) - : base (info, context) { - } - - public override int ErrorCode { - get { - return NativeErrorCode; - } - } - } -} diff --git a/mcs/class/System/System.Net.Sockets/SocketFlags.cs b/mcs/class/System/System.Net.Sockets/SocketFlags.cs deleted file mode 100644 index 12b0906b1ee..00000000000 --- a/mcs/class/System/System.Net.Sockets/SocketFlags.cs +++ /dev/null @@ -1,46 +0,0 @@ -// SocketFlags.cs -// -// This code was automatically generated from -// ECMA CLI XML Library Specification. -// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)] -// Created: Wed, 5 Sep 2001 06:32:49 UTC -// Source file: AllTypes.xml -// URL: http://msdn.microsoft.com/net/ecma/AllTypes.xml -// -// (C) 2001 Ximian, Inc. http://www.ximian.com - - -namespace System.Net.Sockets { - - - /// <summary> - /// </summary> - [Flags] - public enum SocketFlags { - - /// <summary> - /// </summary> - None = 0x00000000, - - /// <summary> - /// </summary> - OutOfBand = 0x00000001, - - /// <summary> - /// </summary> - MaxIOVectorLength = 0x00000010, - - /// <summary> - /// </summary> - Peek = 0x00000002, - - /// <summary> - /// </summary> - DontRoute = 0x00000004, - - /// <summary> - /// </summary> - Partial = 0x00008000, - } // SocketFlags - -} // System.Net.Sockets diff --git a/mcs/class/System/System.Net.Sockets/SocketOptionLevel.cs b/mcs/class/System/System.Net.Sockets/SocketOptionLevel.cs deleted file mode 100644 index 657a4532154..00000000000 --- a/mcs/class/System/System.Net.Sockets/SocketOptionLevel.cs +++ /dev/null @@ -1,37 +0,0 @@ -// SocketOptionLevel.cs -// -// This code was automatically generated from -// ECMA CLI XML Library Specification. -// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)] -// Created: Wed, 5 Sep 2001 06:32:55 UTC -// Source file: AllTypes.xml -// URL: http://msdn.microsoft.com/net/ecma/AllTypes.xml -// -// (C) 2001 Ximian, Inc. http://www.ximian.com - - -namespace System.Net.Sockets { - - - /// <summary> - /// </summary> - public enum SocketOptionLevel { - - /// <summary> - /// </summary> - Socket = 65535, - - /// <summary> - /// </summary> - IP = 0, - - /// <summary> - /// </summary> - Tcp = 6, - - /// <summary> - /// </summary> - Udp = 17, - } // SocketOptionLevel - -} // System.Net.Sockets diff --git a/mcs/class/System/System.Net.Sockets/SocketOptionName.cs b/mcs/class/System/System.Net.Sockets/SocketOptionName.cs deleted file mode 100644 index 117c7fc0225..00000000000 --- a/mcs/class/System/System.Net.Sockets/SocketOptionName.cs +++ /dev/null @@ -1,181 +0,0 @@ -// SocketOptionName.cs -// -// This code was automatically generated from -// ECMA CLI XML Library Specification. -// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)] -// Created: Wed, 5 Sep 2001 06:33:02 UTC -// Source file: AllTypes.xml -// URL: http://msdn.microsoft.com/net/ecma/AllTypes.xml -// -// (C) 2001 Ximian, Inc. http://www.ximian.com - - -namespace System.Net.Sockets { - - - /// <summary> - /// </summary> - public enum SocketOptionName { - - /// <summary> - /// </summary> - Debug = 1, - - /// <summary> - /// </summary> - AcceptConnection = 2, - - /// <summary> - /// </summary> - ReuseAddress = 4, - - /// <summary> - /// </summary> - KeepAlive = 8, - - /// <summary> - /// </summary> - DontRoute = 16, - - /// <summary> - /// </summary> - Broadcast = 32, - - /// <summary> - /// </summary> - UseLoopback = 64, - - /// <summary> - /// </summary> - Linger = 128, - - /// <summary> - /// </summary> - OutOfBandInline = 256, - - /// <summary> - /// </summary> - DontLinger = -129, - - /// <summary> - /// </summary> - ExclusiveAddressUse = -5, - - /// <summary> - /// </summary> - SendBuffer = 4097, - - /// <summary> - /// </summary> - ReceiveBuffer = 4098, - - /// <summary> - /// </summary> - SendLowWater = 4099, - - /// <summary> - /// </summary> - ReceiveLowWater = 4100, - - /// <summary> - /// </summary> - SendTimeout = 4101, - - /// <summary> - /// </summary> - ReceiveTimeout = 4102, - - /// <summary> - /// </summary> - Error = 4103, - - /// <summary> - /// </summary> - Type = 4104, - - /// <summary> - /// </summary> - MaxConnections = 2147483647, - - /// <summary> - /// </summary> - IPOptions = 1, - - /// <summary> - /// </summary> - HeaderIncluded = 2, - - /// <summary> - /// </summary> - TypeOfService = 3, - - /// <summary> - /// </summary> - IpTimeToLive = 4, - - /// <summary> - /// </summary> - MulticastInterface = 9, - - /// <summary> - /// </summary> - MulticastTimeToLive = 10, - - /// <summary> - /// </summary> - MulticastLoopback = 11, - - /// <summary> - /// </summary> - AddMembership = 12, - - /// <summary> - /// </summary> - DropMembership = 13, - - /// <summary> - /// </summary> - DontFragment = 14, - - /// <summary> - /// </summary> - AddSourceMembership = 15, - - /// <summary> - /// </summary> - DropSourceMembership = 16, - - /// <summary> - /// </summary> - BlockSource = 17, - - /// <summary> - /// </summary> - UnblockSource = 18, - - /// <summary> - /// </summary> - PacketInformation = 19, - - /// <summary> - /// </summary> - NoDelay = 1, - - /// <summary> - /// </summary> - BsdUrgent = 2, - - /// <summary> - /// </summary> - Expedited = 2, - - /// <summary> - /// </summary> - NoChecksum = 1, - - /// <summary> - /// </summary> - ChecksumCoverage = 20, - } // SocketOptionName - -} // System.Net.Sockets diff --git a/mcs/class/System/System.Net.Sockets/SocketShutdown.cs b/mcs/class/System/System.Net.Sockets/SocketShutdown.cs deleted file mode 100644 index 0f9e5f269dc..00000000000 --- a/mcs/class/System/System.Net.Sockets/SocketShutdown.cs +++ /dev/null @@ -1,33 +0,0 @@ -// SocketShutdown.cs -// -// This code was automatically generated from -// ECMA CLI XML Library Specification. -// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)] -// Created: Wed, 5 Sep 2001 06:32:43 UTC -// Source file: AllTypes.xml -// URL: http://msdn.microsoft.com/net/ecma/AllTypes.xml -// -// (C) 2001 Ximian, Inc. http://www.ximian.com - - -namespace System.Net.Sockets { - - - /// <summary> - /// </summary> - public enum SocketShutdown { - - /// <summary> - /// </summary> - Receive = 0, - - /// <summary> - /// </summary> - Send = 1, - - /// <summary> - /// </summary> - Both = 2, - } // SocketShutdown - -} // System.Net.Sockets diff --git a/mcs/class/System/System.Net.Sockets/SocketType.cs b/mcs/class/System/System.Net.Sockets/SocketType.cs deleted file mode 100644 index bdb6c54d3c2..00000000000 --- a/mcs/class/System/System.Net.Sockets/SocketType.cs +++ /dev/null @@ -1,45 +0,0 @@ -// SocketType.cs -// -// This code was automatically generated from -// ECMA CLI XML Library Specification. -// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)] -// Created: Wed, 5 Sep 2001 06:32:37 UTC -// Source file: AllTypes.xml -// URL: http://msdn.microsoft.com/net/ecma/AllTypes.xml -// -// (C) 2001 Ximian, Inc. http://www.ximian.com - - -namespace System.Net.Sockets { - - - /// <summary> - /// </summary> - public enum SocketType { - - /// <summary> - /// </summary> - Stream = 1, - - /// <summary> - /// </summary> - Dgram = 2, - - /// <summary> - /// </summary> - Raw = 3, - - /// <summary> - /// </summary> - Rdm = 4, - - /// <summary> - /// </summary> - Seqpacket = 5, - - /// <summary> - /// </summary> - Unknown = -1, - } // SocketType - -} // System.Net.Sockets diff --git a/mcs/class/System/System.Net.Sockets/TcpClient.cs b/mcs/class/System/System.Net.Sockets/TcpClient.cs deleted file mode 100755 index acae2b24cb9..00000000000 --- a/mcs/class/System/System.Net.Sockets/TcpClient.cs +++ /dev/null @@ -1,338 +0,0 @@ -// System.Net.Sockets.TcpClient.cs -// -// Author: -// Phillip Pearson (pp@myelin.co.nz) -// -// Copyright (C) 2001, Phillip Pearson -// http://www.myelin.co.nz -// - -// NB: This is untested (probably buggy) code - take care if using it - -using System; -using System.Net; - -namespace System.Net.Sockets -{ - /// <remarks> - /// A slightly more abstracted way to create an - /// outgoing network connections than a Socket. - /// </remarks> - public class TcpClient : IDisposable - { - // private data - - private NetworkStream stream; - private bool active; - private Socket client; - private bool disposed = false; - - // constructor - - /// <summary> - /// Some code that is shared between the constructors. - /// </summary> - private void Init () - { - active = false; - client = new Socket(AddressFamily.InterNetwork, - SocketType.Stream, ProtocolType.Tcp); - } - - /// <summary> - /// Constructs a new TcpClient with no connection set up - /// </summary> - public TcpClient () - { - Init(); - client.Bind(new IPEndPoint(IPAddress.Any, 0)); - } - - /// <summary> - /// Constructs a new TcpClient with a specified local endpoint. - /// Use this if you want to have your connections originating - /// from a certain port, or a certain IP (on a multi homed - /// system). - /// </summary> - /// <param name="local_end_point">The aforementioned local endpoint</param> - public TcpClient (IPEndPoint local_end_point) - { - Init(); - client.Bind(local_end_point); - } - - /// <summary> - /// Constructs a new TcpClient and connects to a specified - /// host on a specified port. A quick way to set up a network - /// connection. - /// </summary> - /// <param name="hostname">The host to connect to, e.g. - /// 192.168.0.201 or www.myelin.co.nz</param> - /// <param name="port">The port to connect to, e.g. 80 for HTTP</param> - public TcpClient (string hostname, int port) - { - Init(); - client.Bind(new IPEndPoint(IPAddress.Any, 0)); - Connect(hostname, port); - } - - /// <summary> - /// A flag that is 'true' if the TcpClient has an active connection - /// </summary> - protected bool Active - { - get { return active; } - set { active = value; } - } - - /// <summary> - /// The socket that all network comms passes through - /// </summary> - protected Socket Client - { - get { return client; } - set { client = value; } - } - - /// <summary> - /// Internal function to allow TcpListener.AcceptTcpClient - /// to work (it needs to be able to set protected property - /// 'Client') - /// </summary> - /// <param name="s"></param> - internal void SetTcpClient (Socket s) - { - client = s; - stream = new NetworkStream (client, true); - } - - /// <summary> - /// If set, the socket will remain open after it has been - /// instructed to close, in order to send data that remains - /// in the buffer. - /// </summary> - public LingerOption LingerState - { - get { - return (LingerOption)client.GetSocketOption( - SocketOptionLevel.Socket, - SocketOptionName.Linger); - } - set { - client.SetSocketOption( - SocketOptionLevel.Socket, - SocketOptionName.Linger, value); - } - } - - /// <summary> - /// <p>If set, outbound data will be sent at once rather than collected - /// until enough is available to fill a packet.</p> - /// - /// <p>This is the TCP_NODELAY sockopt from BSD sockets and WinSock. - /// For more information, look up the Nagle algorithm.</p> - /// </summary> - public bool NoDelay - { - get { - return (bool)client.GetSocketOption( - SocketOptionLevel.Tcp, - SocketOptionName.NoDelay); - } - set { - client.SetSocketOption( - SocketOptionLevel.Tcp, - SocketOptionName.NoDelay, value); - } - } - - /// <summary> - /// How big the receive buffer is (from the connection socket) - /// </summary> - public int ReceiveBufferSize - { - get { - return (int)client.GetSocketOption( - SocketOptionLevel.Socket, - SocketOptionName.ReceiveBuffer); - } - set { - client.SetSocketOption( - SocketOptionLevel.Socket, - SocketOptionName.ReceiveBuffer, value); - } - } - - /// <summary> - /// How long before the socket will time out on a - /// Receive() call - /// </summary> - public int ReceiveTimeout - { - get { - return (int)client.GetSocketOption( - SocketOptionLevel.Socket, - SocketOptionName.ReceiveTimeout); - } - set { - client.SetSocketOption( - SocketOptionLevel.Socket, - SocketOptionName.ReceiveTimeout, value); - } - } - - /// <summary> - /// How big the send buffer is (from the connection socket) - /// </summary> - public int SendBufferSize - { - get { - return (int)client.GetSocketOption( - SocketOptionLevel.Socket, - SocketOptionName.SendBuffer); - } - set { - client.SetSocketOption( - SocketOptionLevel.Socket, - SocketOptionName.SendBuffer, value); - } - } - - /// <summary> - /// How long before the socket will time out on a - /// Send() call - /// </summary> - public int SendTimeout - { - get { - return (int)client.GetSocketOption( - SocketOptionLevel.Socket, - SocketOptionName.SendTimeout); - } - set { - client.SetSocketOption( - SocketOptionLevel.Socket, - SocketOptionName.SendTimeout, value); - } - } - - - // methods - - /// <summary> - /// Closes the socket and disposes of all managed resources. - /// - /// Throws SocketException if something goes wrong while - /// closing the socket. - /// </summary> - public void Close () - { - ((IDisposable) this).Dispose (); - } - - /// <summary> - /// Connects to a specified remote endpoint - /// - /// Throws SocketException if something goes wrong while - /// connecting. - /// </summary> - /// <param name="remote_end_point">The aforementioned endpoint</param> - public void Connect (IPEndPoint remote_end_point) - { - try { - client.Connect(remote_end_point); - stream = new NetworkStream(client, true); - active = true; - } finally { - CheckDisposed (); - } - } - - /// <summary> - /// Connects to an IP address on a port - /// - /// Throws SocketException if something goes wrong while - /// connecting. - /// </summary> - /// <param name="address">The IP address (get it from Dns.GetHostByName)</param> - /// <param name="port">The port to connect to, e.g. 80 for HTTP</param> - public void Connect (IPAddress address, int port) - { - Connect(new IPEndPoint(address, port)); - } - - /// <summary> - /// Resolves a fully qualified domain name to an IP address - /// and connects to it on a specified port - /// - /// Throws SocketException if something goes wrong while - /// connecting. - /// </summary> - /// <param name="hostname">The hostname, e.g. www.myelin.co.nz</param> - /// <param name="port">The port, e.g. 80 for HTTP</param> - [MonoTODO] - public void Connect (string hostname, int port) - { - CheckDisposed (); - IPHostEntry host = Dns.GetHostByName(hostname); - /* TODO: This will connect to the first IP address returned - from GetHostByName. Is that right? */ - Connect(new IPEndPoint(host.AddressList[0], port)); - } - - /// <summary> - /// Gets rid of all managed resources - /// </summary> - void IDisposable.Dispose () - { - Dispose (true); - GC.SuppressFinalize (this); - } - - /// <summary> - /// Gets rid of all unmanaged resources - /// </summary> - /// <param name="disposing">If this is true, it gets rid of all - /// managed resources as well</param> - protected virtual void Dispose (bool disposing) - { - if (disposed) - return; - disposed = true; - - // release unmanaged resources - NetworkStream s = stream; - stream = null; - if (s != null) { - // This closes the socket as well, as the NetworkStream - // owns the socket. - s.Close(); - active = false; - s = null; - } - client = null; - } - - /// <summary> - /// Destructor - just calls Dispose() - /// </summary> - ~TcpClient () - { - Dispose (false); - } - - /// <returns>A NetworkStream object connected to the - /// connection socket</returns> - public NetworkStream GetStream() - { - try { return stream; } - finally { CheckDisposed (); } - } - - private void CheckDisposed () - { - if (disposed) - throw new ObjectDisposedException (GetType().FullName); - } - } -} diff --git a/mcs/class/System/System.Net.Sockets/TcpListener.cs b/mcs/class/System/System.Net.Sockets/TcpListener.cs deleted file mode 100755 index feedae68b90..00000000000 --- a/mcs/class/System/System.Net.Sockets/TcpListener.cs +++ /dev/null @@ -1,171 +0,0 @@ -// System.Net.Sockets.TcpListener.cs -// -// Author: -// Phillip Pearson (pp@myelin.co.nz) -// -// Copyright (C) 2001, Phillip Pearson -// http://www.myelin.co.nz -// - -// NB: This is untested (probably buggy) code - take care using it - -using System; -using System.Net; - -namespace System.Net.Sockets -{ - /// <remarks> - /// A slightly more abstracted way to listen for incoming - /// network connections than a Socket. - /// </remarks> - public class TcpListener - { - // private data - - private bool active; - private Socket server; - - // constructor - - /// <summary> - /// Some code that is shared between the constructors. - /// </summary> - private void Init () - { - active = false; - server = new Socket(AddressFamily.InterNetwork, - SocketType.Stream, ProtocolType.Tcp); - } - - /// <summary> - /// Constructs a new TcpListener to listen on a specified port - /// </summary> - /// <param name="port">The port to listen on, e.g. 80 if you - /// are a web server</param> - public TcpListener (int port) - { - Init(); - server.Bind(new IPEndPoint(IPAddress.Any, port)); - } - - /// <summary> - /// Constructs a new TcpListener with a specified local endpoint - /// </summary> - /// <param name="local_end_point">The endpoint</param> - public TcpListener (IPEndPoint local_end_point) - { - Init(); - server.Bind(local_end_point); - } - - /// <summary> - /// Constructs a new TcpListener, listening on a specified port - /// and IP (for use on a multi-homed machine) - /// </summary> - /// <param name="listen_ip">The IP to listen on</param> - /// <param name="port">The port to listen on</param> - public TcpListener (IPAddress listen_ip, int port) - { - Init(); - server.Bind(new IPEndPoint(listen_ip, port)); - } - - - // properties - - /// <summary> - /// A flag that is 'true' if the TcpListener is listening, - /// or 'false' if it is not listening - /// </summary> - protected bool Active - { - get { return active; } - } - - /// <summary> - /// The local end point - /// </summary> - public EndPoint LocalEndpoint - { - get { return server.LocalEndPoint; } - } - - /// <summary> - /// The listening socket - /// </summary> - protected Socket Server - { - get { return server; } - } - - - // methods - - /// <summary> - /// Accepts a pending connection - /// <returns>A Socket object for the new connection</returns> - public Socket AcceptSocket () - { - return server.Accept(); - } - - /// <summary> - /// Accepts a pending connection - /// </summary> - /// <returns>A TcpClient - /// object made from the new socket.</returns> - public TcpClient AcceptTcpClient () - { - TcpClient client = new TcpClient(); - // use internal method SetTcpClient to make a - // client with the specified socket - client.SetTcpClient(AcceptSocket()); - return client; - } - - /// <summary> - /// Destructor - stops the listener listening - /// </summary> - ~TcpListener () - { - if (active == true) { - Stop(); - } - } - - /// <returns> - /// Returns 'true' if there is a connection waiting to be accepted - /// with AcceptSocket() or AcceptTcpClient(). - /// </returns> - public bool Pending () - { - return server.Poll(1000, SelectMode.SelectRead); - } - - /// <summary> - /// Tells the TcpListener to start listening. - /// </summary> - [MonoTODO] - public void Start () - { - server.Listen(5); // According to the - // man page some BSD - // and BSD-derived - // systems limit the - // backlog to 5. This - // should really be - // configurable though - active = true; - } - - /// <summary> - /// Tells the TcpListener to stop listening and dispose - /// of all managed resources. - /// </summary> - public void Stop () - { - server.Close(); - } - - } -} diff --git a/mcs/class/System/System.Net.Sockets/UdpClient.cs b/mcs/class/System/System.Net.Sockets/UdpClient.cs deleted file mode 100644 index ceaf9ac9eae..00000000000 --- a/mcs/class/System/System.Net.Sockets/UdpClient.cs +++ /dev/null @@ -1,269 +0,0 @@ -//
-// System.Net.Sockets.UdpClient.cs
-//
-// Author:
-// Gonzalo Paniagua Javier <gonzalo@ximian.com>
-//
-// Copyright (C) Ximian, Inc. http://www.ximian.com
-//
-
-using System;
-using System.Net;
-
-namespace System.Net.Sockets
-{
- public class UdpClient : IDisposable
- {
- private bool disposed = false;
- private bool active = false;
- private Socket socket;
- private IPEndPoint localEP;
-
-#region Constructors
- public UdpClient ()
- {
- localEP = new IPEndPoint (IPAddress.Any, 0);
- InitSocket ();
- }
-
- public UdpClient (int port)
- {
- // IPEndPoint throws ArgumentException when port is invalid
- localEP = new IPEndPoint (IPAddress.Any, port);
- InitSocket ();
- }
-
- public UdpClient (IPEndPoint localEP)
- {
- if (localEP == null)
- throw new ArgumentNullException ("IPEndPoint cannot be null");
-
- this.localEP = localEP;
- InitSocket ();
- }
-
- public UdpClient (string hostname, int port)
- {
- if (hostname == null)
- throw new ArgumentNullException ("hostname cannot be null");
-
- if (port < IPEndPoint.MinPort || port > IPEndPoint.MaxPort)
- throw new ArgumentException ("Invalid port");
-
- localEP = new IPEndPoint (IPAddress.Any, 0);
- InitSocket ();
- Connect (hostname, port);
- }
-
- private void InitSocket ()
- {
- active = false;
- socket = new Socket (AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
- socket.Bind (localEP);
- }
-
-#endregion // Constructors
-#region Public methods
-#region Close
- public void Close ()
- {
- ((IDisposable) this).Dispose ();
- }
-#endregion
-#region Connect
- public void Connect (IPEndPoint endPoint)
- {
- try {
- socket.Connect (endPoint);
- active = true;
- } finally {
- CheckDisposed ();
- }
- }
-
- public void Connect (IPAddress addr, int port)
- {
- Connect (new IPEndPoint (addr, port));
- }
-
- public void Connect (string hostname, int port)
- {
- Connect (new IPEndPoint (Dns.Resolve (hostname).AddressList [0], port));
- }
-#endregion
-#region Multicast methods
- public void DropMulticastGroup (IPAddress multicastAddr)
- {
- try {
- socket.SetSocketOption (SocketOptionLevel.IP, SocketOptionName.DropMembership,
- new MulticastOption (multicastAddr));
- } finally {
- CheckDisposed ();
- }
- }
-
- public void JoinMulticastGroup (IPAddress multicastAddr)
- {
- try {
- socket.SetSocketOption (SocketOptionLevel.IP, SocketOptionName.AddMembership,
- new MulticastOption (multicastAddr));
- } finally {
- CheckDisposed ();
- }
- }
-
- public void JoinMulticastGroup (IPAddress multicastAddr, int timeToLive)
- {
- JoinMulticastGroup (multicastAddr);
- try {
- socket.SetSocketOption (SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive,
- timeToLive);
- } finally {
- CheckDisposed ();
- }
- }
-#endregion
-#region Data I/O
- public byte [] Receive (ref IPEndPoint remoteEP)
- {
- try {
- if (remoteEP == null)
- throw new ArgumentNullException ("remoteEP cannot be null");
-
- // Length of the array for receiving data??
- byte [] recBuffer;
- int available = socket.Available;
-
- recBuffer = new byte [1024]; // FIXME: any suggestions?
- EndPoint endPoint = (EndPoint) remoteEP;
- int dataRead = socket.ReceiveFrom (recBuffer, ref endPoint);
- if (dataRead < recBuffer.Length)
- return CutArray (recBuffer, dataRead);
-
- return recBuffer;
- } finally {
- CheckDisposed ();
- }
- }
-
- public int Send (byte [] dgram, int bytes)
- {
- try {
- if (dgram == null)
- throw new ArgumentNullException ("dgram is null");
-
- byte [] realDgram;
- if (dgram.Length <= bytes)
- realDgram = dgram;
- else
- realDgram = CutArray (dgram, (bytes >= dgram.Length) ? bytes : dgram.Length);
-
- // the socket should be connected already, so I use Send instead of SendTo
- return socket.Send (realDgram);
- } finally {
- CheckDisposed ();
- }
- }
-
- public int Send (byte [] dgram, int bytes, IPEndPoint endPoint)
- {
- try {
- if (dgram == null)
- throw new ArgumentNullException ("dgram is null");
-
- byte [] realDgram;
- if (dgram.Length <= bytes)
- realDgram = dgram;
- else
- realDgram = CutArray (dgram, (bytes >= dgram.Length) ? bytes : dgram.Length);
-
- // the socket should not be connected
- return socket.SendTo (realDgram, endPoint);
- } finally {
- CheckDisposed ();
- }
- }
-
- public int Send (byte [] dgram, int bytes, string hostname, int port)
- {
- return Send (dgram, bytes,
- new IPEndPoint (Dns.Resolve (hostname).AddressList [0], port));
- }
-
- private byte [] CutArray (byte [] orig, int length)
- {
- byte [] newArray = new byte [length];
- Array.Copy (orig, 0, newArray, 0, length);
-
- return newArray;
- }
-#endregion
-#region Properties
- protected bool Active {
- get { return active; }
- set { active = value; }
- }
-
- protected Socket Client {
- get { return socket; }
- set { socket = value; }
- }
-#endregion
-
-/*
-// commented because in the ms.net implementation these are not overriden. -- LP
-#region Overrides
- public override bool Equals (object obj)
- {
- if (obj is UdpClient)
- return (((UdpClient) obj).socket == socket &&
- ((UdpClient) obj).localEP == localEP);
-
- return false;
- }
-
- public override int GetHashCode ()
- {
- return (socket.GetHashCode () + localEP.GetHashCode () + (active ? 1 : 0));
- }
-#endregion
-*/
-
-#region Disposing
- void IDisposable.Dispose ()
- {
- Dispose (true);
- GC.SuppressFinalize (this);
- }
-
- void Dispose (bool disposing)
- {
- if (disposed)
- return;
- disposed = true;
- if (disposing) {
- // release managed resources
- localEP = null;
- }
- // release unmanaged resources
- Socket s = socket;
- socket = null;
- if (s != null)
- s.Close ();
- }
-
- ~UdpClient ()
- {
- Dispose (false);
- }
-
- private void CheckDisposed ()
- {
- if (disposed)
- throw new ObjectDisposedException (GetType().FullName);
- }
-#endregion
-#endregion
- }
-}
-
|