// System.Net.Sockets.Socket.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 // Nowhere near finished yet ... using System; using System.Net; using System.Collections; namespace System.Net.Sockets { public class Socket : IDisposable { // static method: /// /// Blocks while waiting for readability, writeability or /// error conditions on a number of sockets /// /// A list of sockets to watch /// for readability /// A list of sockets to watch /// for writeability /// A list of sockets to watch /// for errors /// Timeout, in microseconds public static void Select ( IList read_list, IList write_list, IList err_list, int time_us) { throw new NotImplementedException(); } // public constructor: /// /// Makes a new Socket /// /// Address family (e.g. /// AddressFamily.InterNetwork for IPv4) /// Socket Type (e.g. SocketType.Stream /// for stream sockets) /// Protocol (e.g. /// ProtocolType.Tcp for TCP) public Socket ( AddressFamily family, SocketType type, ProtocolType proto) { throw new NotImplementedException(); } // public properties: /// /// The address family (see contructor) /// public AddressFamily AddressFamily { get { throw new NotImplementedException(); //return AddressFamily.InterNetwork; } } /// /// How much data is waiting to be read (i.e. the amount /// of data in the in buffer) /// public int Available { get { throw new NotImplementedException(); //return 0; } } /// /// A flag to indicate whether the socket is a blocking /// socket or not. Returns true if blocking. /// /// A non-blocking socket (Blocking == false) will return /// control to the application immediately if any calls are /// made that may take a while to complete. Blocking /// sockets will block the app until whatever they are doing /// is finished. /// public bool Blocking { get { throw new NotImplementedException(); //return false; } set { } } /// /// A flag to say whether the socket is connected to something /// or not. /// /// Returns true if connected. /// public bool Connected { get { throw new NotImplementedException(); //return false; } } /// /// A handle to the socket (its file descriptor?) /// public IntPtr Handle { get { throw new NotImplementedException(); //return new IntPtr(0); } } /// /// The socket's local endpoint (where it's coming from) /// public EndPoint LocalEndPoint { get { throw new NotImplementedException(); //return new IPEndPoint(0,0); } } /// /// Protocol type (e.g. Tcp, Udp) /// public ProtocolType ProtocolType { get { throw new NotImplementedException(); //return ProtocolType.Tcp; } } /// /// The socket's remote endpoint (where it's connected to) /// public EndPoint RemoteEndPoint { get { throw new NotImplementedException(); //return new IPEndPoint(0,0); } } /// /// Socket type (e.g. datagram, stream) /// public SocketType SocketType { get { throw new NotImplementedException(); //return SocketType.Stream; } } // public methods: /// /// Accepts a new connection /// /// A new socket to handle the connection public Socket Accept () { throw new NotImplementedException(); //return new Socket(AddressFamily.InterNetwork, // SocketType.Stream, ProtocolType.Tcp); } /// /// Accepts the connection in the background, /// calling the application back when finished. /// /// A delegate to be called /// when the accept is finished /// State information for this call /// public IAsyncResult BeginAccept ( AsyncCallback callback, object state) { throw new NotImplementedException(); } /// /// Connects to a remote endpoint in the background, /// calling back when finished. /// /// The endpoint to /// connect to /// Where to call when done /// State information for this call /// public IAsyncResult BeginConnect ( EndPoint remote_end_point, AsyncCallback callback, object state) { throw new NotImplementedException(); } /// /// Receives data in the background, calling /// back when finished. /// /// A buffer to put the data into as it /// arrives /// Where to put the data (offset into /// the buffer) /// Buffer size /// Socket flags /// Where to call when the /// operation is finished /// State info for this call /// public IAsyncResult BeginReceive ( byte[] buffer, int offset, int size, SocketFlags socket_flags, AsyncCallback callback, object state) { throw new NotImplementedException(); } /// /// Receives data in the background from a specific /// point, calling back when finished. /// /// A buffer to put the data into as it /// arrives /// Where to put the data (offset into /// the buffer) /// Buffer size /// Socket flags /// Where to receive from /// Where to call when the /// operation is finished /// State info for this call /// public IAsyncResult BeginReceiveFrom ( byte[] buffer, int offset, int size, SocketFlags socket_flags, ref EndPoint remote_end_point, AsyncCallback callback, object state) { throw new NotImplementedException(); } /// /// Starts sending data somewhere, in the background. /// /// Buffer containing the data to send /// Where in the buffer to start sending from /// Buffer size /// Socket flags /// Where to call back to when finished /// State info for this call /// public IAsyncResult BeginSend ( byte[] buffer, int offset, int size, SocketFlags socket_flags, AsyncCallback callback, object state) { throw new NotImplementedException(); } /// /// Starts sending data to a specific point, in the background /// /// /// /// /// /// /// Where to call back to when /// finished sending /// /// public IAsyncResult BeginSendTo ( byte[] buffer, int offset, int size, SocketFlags socket_flags, EndPoint remote_end_point, AsyncCallback callback, object state) { throw new NotImplementedException(); } /// /// Binds the socket to a local endpoint /// /// What to /// bind it to public void Bind (EndPoint local_end_point) { throw new NotImplementedException(); } /// /// Closes the socket /// public void Close () { throw new NotImplementedException(); } /// /// Connects to a remote system /// /// Where to connect to public void Connect (EndPoint remote_end_point) { throw new NotImplementedException(); } /// /// Completes an Accept() operation started /// with a BeginAccept() call /// /// /// public Socket EndAccept (IAsyncResult result) { throw new NotImplementedException(); } /// /// Completes an asynchronous Connect() operation /// started with a BeginConnect() call /// /// public void EndConnect (IAsyncResult result) { throw new NotImplementedException(); } /// /// Completes an asynchronous Receive() operation /// started with a BeginReceive() call /// /// /// public int EndReceive (IAsyncResult result) { throw new NotImplementedException(); } /// /// Completes an asynchronous ReceiveFrom() operation /// started with a BeginReceiveFrom() call /// /// /// /// public int EndReceiveFrom ( IAsyncResult result, ref EndPoint end_point) { throw new NotImplementedException(); } /// /// Completes an asynchronous Send() operation /// started with a BeginSend() call /// /// /// public int EndSend (IAsyncResult result) { throw new NotImplementedException(); } /// /// Completes an asynchronous SendTo() operation /// started with a BeginSendTo() call /// /// /// public int EndSendTo (IAsyncResult result) { throw new NotImplementedException(); } /// /// Gets a socket option /// /// /// /// public object GetSocketOption ( SocketOptionLevel level, SocketOptionName name) { throw new NotImplementedException(); } /// /// Gets a socket option /// /// /// /// public void GetSocketOption ( SocketOptionLevel level, SocketOptionName name, byte[] opt_value) { throw new NotImplementedException(); } /// /// Gets a socket option /// /// /// /// /// public byte[] GetSocketOption ( SocketOptionLevel level, SocketOptionName name, int length) { throw new NotImplementedException(); } /// /// Does something to the socket, a la ioctl() /// /// Code of the operation /// to perform on the socket /// Data to pass to ioctl() /// Data returned from ioctl() /// public int IOControl ( int ioctl_code, byte[] in_value, byte[] out_value) { throw new NotImplementedException(); } /// /// Tells the socket to start listening /// /// Connection backlog - the number /// of pending (not Accept()ed) connections that will be /// allowed before new connections are automatically /// refused public void Listen (int backlog) { throw new NotImplementedException(); } /// /// Blocks the application until the socket is either /// readable, writeable or has an error condition /// /// How long to wait, in microseconds /// What to wait for (reading, writing, error) /// public bool Poll (int time_us, SelectMode mode) { throw new NotImplementedException(); } /// /// Receives data from the socket /// /// /// public int Receive ( byte[] buf) { throw new NotImplementedException(); } /// /// Receives data from the socket /// /// /// /// public int Receive ( byte[] buf, SocketFlags flags) { throw new NotImplementedException(); } /// /// Receives data from the socket /// /// /// /// /// public int Receive ( byte[] buf, int size, SocketFlags flags) { throw new NotImplementedException(); } /// /// Receives data from the socket /// /// /// /// /// /// public int Receive ( byte[] buf, int offset, int size, SocketFlags flags) { throw new NotImplementedException(); } /// /// Receives data from a specific point, /// through the socket /// /// /// /// public int ReceiveFrom ( byte[] buf, ref EndPoint remote_end_point) { throw new NotImplementedException(); } /// /// Receives data from a specific point, /// through the socket /// /// /// /// /// public int ReceiveFrom ( byte[] buf, SocketFlags flags, ref EndPoint remote_end_point) { throw new NotImplementedException(); } /// /// Receives data from a specific point, /// through the socket /// /// /// /// /// /// public int ReceiveFrom ( byte[] buf, int size, SocketFlags flags, ref EndPoint remote_end_point) { throw new NotImplementedException(); } /// /// Receives data from a specific point, /// through the socket /// /// /// /// /// /// /// public int ReceiveFrom ( byte[] buf, int offset, int size, SocketFlags flags, ref EndPoint remote_end_point) { throw new NotImplementedException(); } /// /// Sends data through the socket /// /// /// public int Send ( byte[] buffer) { throw new NotImplementedException(); } /// /// Sends data through the socket /// /// /// /// public int Send ( byte[] buffer, SocketFlags flags) { throw new NotImplementedException(); } /// /// Sends data through the socket /// /// /// /// /// public int Send ( byte[] buffer, int size, SocketFlags flags) { throw new NotImplementedException(); } /// /// Sends data through the socket /// /// /// /// /// /// public int Send ( byte[] buffer, int offset, int size, SocketFlags flags) { throw new NotImplementedException(); } /// /// Sends data to a specific point, /// through the socket /// /// /// /// public int SendTo ( byte[] buffer, EndPoint remote_end_point) { throw new NotImplementedException(); } /// /// Sends data to a specific point, /// through the socket /// /// /// /// /// public int SendTo ( byte[] buffer, SocketFlags flags, EndPoint remote_end_point) { throw new NotImplementedException(); } /// /// Sends data to a specific point, /// through the socket /// /// /// /// /// /// public int SendTo ( byte[] buffer, int size, SocketFlags flags, EndPoint remote_end_point) { throw new NotImplementedException(); } /// /// Sends data to a specific point, /// through the socket /// /// /// /// /// /// /// public int SendTo ( byte[] buffer, int offset, int size, SocketFlags flags, EndPoint remote_end_point) { throw new NotImplementedException(); } /// /// Sets a socket option (like setsockopt()) /// /// /// /// public void SetSocketOption ( SocketOptionLevel level, SocketOptionName name, byte[] opt_value) { throw new NotImplementedException(); } /// /// Sets a socket option (like setsockopt()) /// /// /// /// public void SetSocketOption ( SocketOptionLevel level, SocketOptionName name, int opt_value) { throw new NotImplementedException(); } /// /// Sets a socket option (like setsockopt()) /// /// /// /// public void SetSocketOption ( SocketOptionLevel level, SocketOptionName name, object opt_value) { throw new NotImplementedException(); } /// /// Stops anyone from being able to read or write to the socket /// /// What people aren't allowed to do any /// more (you can disable just reading or just writing, or both) public void Shutdown (SocketShutdown how) { throw new NotImplementedException(); } /// /// A stringified representation of the socket /// /// public override string ToString () { throw new NotImplementedException(); //return "foo"; } // protected methods: /// /// Disposes of all unmanaged resources, and /// managed resources too if requested /// /// Set this to true /// to dispose of managed resources protected virtual void Dispose (bool disposing) { // file descriptor / socket // other things to dispose of? // managed things? throw new NotImplementedException(); } /// /// Disposes of everything (managed and /// unmanaged resources) /// public void Dispose () { Dispose(true); } /// /// Destructor - disposes of unmanaged resources /// ~Socket () { Dispose(false); throw new NotImplementedException(); } } }