Networking System [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ] 1.0.x.x 1.0.5000.0 2.0.0.0 All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe. System.Object System.IDisposable

Creates a communication endpoint through which an application sends or receives data across a network.

This class enables a instance to communicate with another socket across a network. The communication can be through connection-oriented and connectionless protocols using either data streams or datagrams (discrete message packets).

Message-oriented protocols preserve message boundaries and require that for each method call there is one corresponding method call. For stream-oriented protocols, data is transmitted without regards to message boundaries. In this case, for example, multiple method calls might be necessary to retrieve all the data from one method call. The protocol is set in the

class constructor.

A instance has a local and a remote endpoint associated with it. The local endpoint contains the connection information for the current socket instance. The remote endpoint contains the connection information for the socket that the current instance communicates with. The endpoints are required to be an instance of a type derived from the class. For the Transmission Control Protocol (TCP) and User Datagram Protocol (UDP) protocols, an endpoint includes the address family, an Internet Protocol (IP) address, and a port number. For connection-oriented protocols (for example, TCP), the remote endpoint does not have to be specified when transferring data. For connectionless protocols (for example, UDP), the remote endpoint is required to be specified.

Methods are provided for both synchronous and asynchronous operations. A synchronous method can operate in blocking mode, in which it waits (blocks) until the operation is complete before returning, or in non-blocking mode, where it returns immediately, possibly before the operation has completed. The blocking mode is set through the property.

An asynchronous method returns immediately and, by convention, relies on a delegate to complete the operation. Asynchronous methods have names which correspond to their synchronous counterparts prefixed with either 'Begin' or End'. For example, the synchronous method has asynchronous counterpart methods named and . The example for the method shows the basic steps for using an asynchronous operation. A complete working example follows this discussion.

Connection-oriented protocols commonly use the client/server model. In this model, one of the sockets is set up as a server, and one or more sockets are set up as clients. A general procedure demonstrating the synchronous communication process for this model is as follows.

On the server-side:

Create a socket to listen for incoming connection requests.
Set the local endpoint using the method.
Put the socket in the listening state using the method.
At this point incoming connection requests from a client are placed in a queue.
Use the method to create a server socket for a connection request issued by a client-side socket. This sets the remote endpoint.
Use the and methods to communicate with the client socket.
When communication is finished, terminate the connection using the method.
Release the resources allocated by the server socket using the method.
Release the resources allocated by the listener socket using the method.

On the client-side:

Create the client socket.
Connect to the server socket using the method. This sets both the local and remote endpoints for the client socket.
Use the and methods to communicate with the server socket.
When communication is finished, terminate the connection using the method.
Release

the resources allocated by the client socket using the

method.

The shutdown step in the previous procedure is not necessary but ensures that any pending data is not lost. If the method is not called, the method shuts down the connection either gracefully or by force. A graceful closure attempts to transfer all pending data before the connection is terminated. Use the socket option to specify a graceful closure for a socket.

This implementation is based on the UNIX sockets implementation in the Berkeley Software Distribution (BSD, release 4.3) from the University of California at Berkeley.

The following examples provide a client/server application that demonstrates the use of asynchronous communication between sockets. Run the client and server on different consoles.

The following code is for the server application. Start this application before the client application.

`using System; using System.Threading; using System.Text; using System.Net; using System.Net.Sockets; public class Server { // used to pass state information to delegate internal class StateObject { internal byte[] sBuffer; internal Socket sSocket; internal StateObject(int size, Socket sock) { sBuffer = new byte[size]; sSocket = sock; } } static void Main() { IPAddress ipAddress = Dns.Resolve( Dns.GetHostName() ).AddressList[0]; IPEndPoint ipEndpoint = new IPEndPoint(ipAddress, 1800); Socket listenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); listenSocket.Bind(ipEndpoint); listenSocket.Listen(1); IAsyncResult asyncAccept = listenSocket.BeginAccept( new AsyncCallback(Server.acceptCallback), listenSocket ); // could call listenSocket.EndAccept(asyncAccept) here // instead of in the callback method, but since // EndAccept blocks, the behavior would be similar to // calling the synchronous Accept method Console.Write("Connection in progress."); if( writeDot(asyncAccept) == true ) { // allow time for callbacks to // finish before the program ends Thread.Sleep(3000); } } public static void acceptCallback(IAsyncResult asyncAccept) { Socket listenSocket = (Socket)asyncAccept.AsyncState; Socket serverSocket = listenSocket.EndAccept(asyncAccept); // arriving here means the operation completed // (asyncAccept.IsCompleted = true) but not // necessarily successfully if( serverSocket.Connected == false ) { Console.WriteLine( ".server is not connected." ); return; } else Console.WriteLine( ".server is connected." ); listenSocket.Close(); StateObject stateObject = new StateObject(16, serverSocket); // this call passes the StateObject because it // needs to pass the buffer as well as the socket IAsyncResult asyncReceive = serverSocket.BeginReceive( stateObject.sBuffer, 0, stateObject.sBuffer.Length, SocketFlags.None, new AsyncCallback(receiveCallback), stateObject); Console.Write("Receiving data."); writeDot(asyncReceive); } public static void receiveCallback(IAsyncResult asyncReceive) { StateObject stateObject = (StateObject)asyncReceive.AsyncState; int bytesReceived = stateObject.sSocket.EndReceive(asyncReceive); Console.WriteLine( ".{0} bytes received: {1}", bytesReceived.ToString(), Encoding.ASCII.GetString(stateObject.sBuffer) ); byte[] sendBuffer = Encoding.ASCII.GetBytes("Goodbye"); IAsyncResult asyncSend = stateObject.sSocket.BeginSend( sendBuffer, 0, sendBuffer.Length, SocketFlags.None, new AsyncCallback(sendCallback), stateObject.sSocket); Console.Write("Sending response."); writeDot(asyncSend); } public static void sendCallback(IAsyncResult asyncSend) { Socket serverSocket = (Socket)asyncSend.AsyncState; int bytesSent = serverSocket.EndSend(asyncSend); Console.WriteLine( ".{0} bytes sent.{1}{1}Shutting down.", bytesSent.ToString(), Environment.NewLine ); serverSocket.Shutdown(SocketShutdown.Both); serverSocket.Close(); } // times out after 20 seconds but operation continues internal static bool writeDot(IAsyncResult ar) { int i = 0; while( ar.IsCompleted == false ) { if( i++ > 40 ) { Console.WriteLine("Timed out."); return false; } Console.Write("."); Thread.Sleep(500); } return true; } }`

The following code is for the client application. When starting the application, supply the hostname of the console running the server application as an input parameter (for example, ProgramName ).

`using System; using System.Threading; using System.Text; using System.Net; using System.Net.Sockets; public class Client { // used to pass state information to delegate class StateObject { internal byte[] sBuffer; internal Socket sSocket; internal StateObject(int size, Socket sock) { sBuffer = new byte[size]; sSocket = sock; } } static void Main(string[] argHostName) { IPAddress ipAddress = Dns.Resolve( argHostName[0] ).AddressList[0]; IPEndPoint ipEndpoint = new IPEndPoint(ipAddress, 1800); Socket clientSocket = new Socket( AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); IAsyncResult asyncConnect = clientSocket.BeginConnect( ipEndpoint, new AsyncCallback(connectCallback), clientSocket ); Console.Write("Connection in progress."); if( writeDot(asyncConnect) == true ) { // allow time for callbacks to // finish before the program ends Thread.Sleep(3000); } } public static void connectCallback(IAsyncResult asyncConnect) { Socket clientSocket = (Socket)asyncConnect.AsyncState; clientSocket.EndConnect(asyncConnect); // arriving here means the operation completed // (asyncConnect.IsCompleted = true) but not // necessarily successfully if( clientSocket.Connected == false ) { Console.WriteLine( ".client is not connected." ); return; } else Console.WriteLine( ".client is connected." ); byte[] sendBuffer = Encoding.ASCII.GetBytes("Hello"); IAsyncResult asyncSend = clientSocket.BeginSend( sendBuffer, 0, sendBuffer.Length, SocketFlags.None, new AsyncCallback(sendCallback), clientSocket); Console.Write("Sending data."); writeDot(asyncSend); } public static void sendCallback(IAsyncResult asyncSend) { Socket clientSocket = (Socket)asyncSend.AsyncState; int bytesSent = clientSocket.EndSend(asyncSend); Console.WriteLine( ".{0} bytes sent.", bytesSent.ToString() ); StateObject stateObject = new StateObject(16, clientSocket); // this call passes the StateObject because it // needs to pass the buffer as well as the socket IAsyncResult asyncReceive = clientSocket.BeginReceive( stateObject.sBuffer, 0, stateObject.sBuffer.Length, SocketFlags.None, new AsyncCallback(receiveCallback), stateObject); Console.Write("Receiving response."); writeDot(asyncReceive); } public static void receiveCallback(IAsyncResult asyncReceive) { StateObject stateObject = (StateObject)asyncReceive.AsyncState; int bytesReceived = stateObject.sSocket.EndReceive(asyncReceive); Console.WriteLine( ".{0} bytes received: {1}{2}{2}Shutting down.", bytesReceived.ToString(), Encoding.ASCII.GetString(stateObject.sBuffer), Environment.NewLine ); stateObject.sSocket.Shutdown(SocketShutdown.Both); stateObject.sSocket.Close(); } // times out after 2 seconds but operation continues internal static bool writeDot(IAsyncResult ar) { int i = 0; while( ar.IsCompleted == false ) { if( i++ > 20 ) { Console.WriteLine("Timed out."); return false; } Console.Write("."); Thread.Sleep(100); } return true; } }`

The output of the server application is

Connection in progress...........server is connected.

Receiving data......5 bytes received: Hello

Sending response....7 bytes sent.

Shutting down.

-----------------------------------------

The output of the client application is

Connection in progress......client is connected.

Sending data......5 bytes sent.

Receiving response......7 bytes received: Goodbye

Shutting down.

- Constructor
  2.0.0.0
  To be added.
  To be added.
  To be added.
- Constructor
  To be added.
  To be added.
  To be added.

  Constructs and initializes a new instance of the class.

  The parameter specifies the addressing scheme used by the current instance, the parameter specifies the socket type of the current instance, and the parameter specifies the protocol used by the current instance. The three parameters are not independent. Some address families restrict which protocols are used, and often the socket type is determined by the protocol. When the specified values are not a valid combination, a exception is thrown.

  Using the member of either the or enumeration, results in a exception being thrown.

  The combination of , , and is invalid.

  -or-

  An error occurred while creating the socket.

  For additional information on causes of the , see the class.

  0
  1.0.5000.0
  2.0.0.0
- Method
  System.Net.Sockets.Socket

  Creates and initializes a new instance and connects it to an incoming connection request.

  A new connected instance.

  This method is used only on the server-side of connection-oriented protocols. It extracts the first connection request from the queue of pending requests, creates a new instance, and connects this instance to the socket associated with the request.

  The property of the socket determines the behavior of this method when there are no pending connection requests. When , this method will throw a . When , this method blocks.

  The following properties of the new instance returned by this method have values identical to the corresponding properties of the current instance:

  The property of the new instance is set to the local endpoint of the first request in the input queue. The property is set to .

  An error occurred while creating the new .

  An asynchronous call is pending and a blocking method has been called.

  An error occurred while accessing the listening socket or while creating the new socket.

  -or-

  The property is set to .

  For additional information on causes of the , see the class.

  The current instance has been disposed. 0 1.0.5000.0 2.0.0.0
- Method
  2.0.0.0
  System.Boolean `` To be added. To be added. To be added. To be added.
- Property
  System.Net.Sockets.AddressFamily

  Gets the address family of the current instance.

  One of the values defined in the enumeration.

  This property is read-only.

  This property is set by the constructor for the current instance. The value of this property specifies the addressing scheme used by the current instance to resolve an address.

  0
  1.0.5000.0
  2.0.0.0
- Property
  System.Int32

  Gets the amount of data available to be read in a single or call.

  A containing the number of bytes of data that are available to be read.

  This property is read-only.

  When the current instance is stream-oriented (for example, the socket type), the available data is generally the total amount of data queued on the current instance.

  When the current instance is message-oriented (for example, the socket type), the available data is the first message in the input queue.

  An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  The current instance has been disposed. 0 1.0.5000.0 2.0.0.0
- Method
  System.IAsyncResult `` `` A delegate, or . An application-defined object, or .

  Begins an asynchronous operation to accept an incoming connection request.

  A instance that contains information about the asynchronous operation.

  To retrieve the results of the operation and release resources allocated by the method, call the method, and specify the object returned by this method.

  The method should be called exactly once for each call to the method.

  If the parameter is not , the method referenced by is invoked when the asynchronous operation completes. The object returned by this method is passed as the argument to the method referenced by . The method referenced by can retrieve the results of the operation by calling the method.

  The parameter can be any object that the caller wishes to have available for the duration of the asynchronous operation. This object is available via the property of the object returned by this method.

  To determine the connection status, check the property, or use either the or method.

  For more information, see , the synchronous version of this method.

  An error occurred while accepting the connection.

  For additional information on causes of the , see the class.

  The current instance has been disposed.

  The following excerpt from the class overview example outlines an asynchronous accept operation.

  `public class Server { static void Main() { . . . listenSocket.BeginAccept( new AsyncCallback(Server.acceptCallback), listenSocket); . . . // EndAccept can be called here . . . } public static void acceptCallback(IAsyncResult asyncAccept) { Socket listenSocket = (Socket)asyncAccept.AsyncState; Socket serverSocket = listenSocket.EndAccept(asyncAccept); serverSocket.BeginReceive(...); . . . } }` 0 1.0.5000.0 2.0.0.0
- Method
  2.0.0.0
  System.IAsyncResult `` `` `` To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  2.0.0.0
  System.IAsyncResult `` `` `` `` To be added. To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  System.IAsyncResult `` `` `` To be added. A delegate, or . An application-defined object, or .

  Begins an asynchronous operation to associate the current instance with a remote endpoint.

  A instance that contains information about the asynchronous operation.

  To release resources allocated by the method, call the method, and specify the object returned by this

  method.

  The method should be called exactly once for each call to the method.

  If the parameter is not , the method referenced by is invoked when the asynchronous operation completes. The object returned by this method is passed as the argument to the method referenced by . The method referenced by can retrieve the results of the operation by calling the method.

  The parameter can be any object that the caller wishes to have available for the duration of the asynchronous operation. This object is available via the property of the object returned by this method.

  To determine the connection status, check the property, or use either the or method.

  For more information, see , the synchronous version of this method.

  is .

  An error occurred while making the connection.

  For additional information on causes of the , see the class.

  The current instance has been disposed. A caller higher in the call stack does not have permission for the requested operation. Requires permission to make a connection to the endpoint defined by . See .

  For an outline of an asynchronous operation, see the method. For the complete example, which uses the method, see the class overview.

  0
  1.0.5000.0
  2.0.0.0
- Method
  2.0.0.0
  System.IAsyncResult `` `` `` `` To be added. To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  2.0.0.0
  System.IAsyncResult `` `` `` `` To be added. To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  2.0.0.0
  System.IAsyncResult `` `` `` `` To be added. To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  2.0.0.0
  System.IAsyncResult `` `` `` To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  2.0.0.0
  System.CLSCompliant(false)
  System.IAsyncResult `` `` `` `` To be added. To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  2.0.0.0
  System.CLSCompliant(false)
  System.IAsyncResult `` `` `` `` `` To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  System.IAsyncResult `` `` `` `` `` `` A array to store data received from the socket. A containing the zero-based position in to begin storing the received data. A containing the number of bytes to receive. To be added. A delegate, or . An application-defined object, or .

  Begins an asynchronous operation to receive data from a socket.

  A instance that contains information about the asynchronous operation.

  To retrieve the results of the operation and release resources allocated by the method, call the method, and specify the object returned by this

  method.

  The method should be called exactly once for each call to the method.

  If the parameter is not , the method referenced by is invoked when the asynchronous operation completes. The object returned by this method is passed as the argument to the method referenced by . The method referenced by can retrieve the results of the operation by calling the method.

  The parameter can be any object that the caller wishes to have available for the duration of the asynchronous operation. This object is available via the property of the object returned by this method.

  For more information, see , the synchronous version of this method.

  is .

  < 0.

  -or-

  > .Length.

  -or-

  < 0.

  -or-

  > .Length - .

  is not a valid combination of values.

  -or-

  An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  The current instance has been disposed.

  For an outline of an asynchronous operation, see the method. For the complete example, which uses the method, see the class overview.

  0
  1.0.5000.0
  2.0.0.0
- Method
  2.0.0.0
  System.IAsyncResult `` `` `` `` `` `` `` To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  System.IAsyncResult `` `` `` `` `` `` `` A array to store data received from the socket. A containing the zero-based position in to begin storing the received data. A containing the number of bytes to receive. To be added. To be added. A delegate, or . An application-defined object, or .

  Begins an asynchronous operation to receive data from a socket and, for connectionless protocols, store the endpoint associated with the socket that sent the data.

  A instance that contains information about the asynchronous operation.

  To retrieve the results of the operation and release resources allocated by the method, call the method, and specify the object returned by this

  method.

  The method should be called exactly once for each call to the method.

  If the parameter is not , the method referenced by is invoked when the asynchronous operation completes. The object returned by this method is passed as the argument to the method referenced by . The method referenced by can retrieve the results of the operation by calling the method.

  The parameter can be any object that the caller wishes to have available for the duration of the asynchronous operation. This object is available via the property of the object returned by this method.

  For more information, see , the synchronous version of this method.

  is .

  -or-

  is .

  < 0.

  -or-

  > .Length.

  -or-

  < 0.

  -or-

  > .Length - .

  is not a valid combination of values.

  -or-

  An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  The current instance has been disposed. A caller in the call stack does not have the required permissions.

  Requires permission to accept a connection on the endpoint defined by the property of the current instance. See .

  Requires permission to make a connection to the endpoint defined by . See .

  For an outline of an asynchronous operation, see the method. For the complete example, see .

  0
  1.0.5000.0
  2.0.0.0
- Method
  2.0.0.0
  System.IAsyncResult `` `` `` `` `` `` `` To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  2.0.0.0
  System.IAsyncResult `` `` `` `` To be added. To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  2.0.0.0
  System.CLSCompliant(false)
  System.IAsyncResult `` `` `` `` `` To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  System.IAsyncResult `` `` `` `` `` `` A array storing data to send to the socket. A containing the zero-based position in containing the starting location of the data to send. A containing the number of bytes to send. To be added. A delegate, or . An application-defined object, or .

  Begins an asynchronous operation to send data to a connected socket.

  A instance that contains information about the asynchronous operation.

  To retrieve the results of the operation and release resources allocated by the method, call the method, and specify the object returned by this

  method.

  The method should be called exactly once for each call to the method.

  If the parameter is not , the method referenced by is invoked when the asynchronous operation completes. The object returned by this method is passed as the argument to the method referenced by . The method referenced by can retrieve the results of the operation by calling the method.

  The parameter can be any object that the caller wishes to have available for the duration of the asynchronous operation. This object is available via the property of the object returned by this method.

  For more information, see , the synchronous version of this method.

  is .

  < 0.

  -or-

  > .Length.

  -or-

  < 0.

  -or-

  > .Length - .

  is not a valid combination of values.

  -or-

  An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  The current instance has been disposed.

  For an outline of an asynchronous operation, see the method. For the complete example, which uses the method, see the class overview.

  0
  1.0.5000.0
  2.0.0.0
- Method
  2.0.0.0
  System.IAsyncResult `` `` `` `` `` `` `` To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  2.0.0.0
  System.IAsyncResult `` `` `` To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  2.0.0.0
  System.IAsyncResult `` `` `` `` `` `` To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  System.IAsyncResult `` `` `` `` `` `` `` A array storing data to send to the socket. A containing the zero-based position in to begin sending data. A containing the number of bytes to send. To be added. To be added. A delegate, or . An application-defined object, or .

  Begins an asynchronous operation to send data to the socket associated with the specified endpoint.

  A instance that contains information about the asynchronous operation.

  To retrieve the results of the operation and release resources allocated by the method, call the method, and specify the object returned by this

  method.

  The method should be called exactly once for each call to the method.

  If the parameter is not , the method referenced by is invoked when the asynchronous operation completes. The object returned by this method is passed as the argument to the method referenced by . The method referenced by can retrieve the results of the operation by calling the method.

  The parameter can be any object that the caller wishes to have available for the duration of the asynchronous operation. This object is available via the property of the object returned by this method.

  For more information, see , the synchronous version of this method.

  is .

  -or-

  is .

  < 0.

  -or-

  > .Length.

  -or-

  < 0.

  -or-

  > .Length - .

  is not a valid combination of values.

  -or-

  An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  The current instance has been disposed. A caller in the call stack does not have the required permissions.

  Requires permission to make a connection to the endpoint defined by . See .

  For an outline of an asynchronous operation, see the method. For the complete example, see the class overview.

  0
  1.0.5000.0
  2.0.0.0
- Method
  System.Void ``

  The local to be associated with the socket.

  Associates the current instance with a local endpoint.

  This method sets the property of the current instance to .

  For connection-oriented protocols, this method is generally used only on the server-side and is required to be called before the first call to the method. On the client-side, binding is usually performed implicitly by the method.

  For connectionless protocols, the , and methods bind the current instance to the local endpoint if the current instance has not previously been bound.

  is . An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  The current instance has been disposed. A caller in the call stack does not have the required permission. Requires permission to accept connections on the endpoint defined by . See . 0 1.0.5000.0 2.0.0.0
- Property
  System.Boolean

  Gets or sets a value that indicates whether the socket is in blocking mode.

  indicates that the current instance is in blocking mode; indicates that the current instance is in non-blocking mode.

  Blocking is when a method waits to complete an operation before returning. Sockets are created in blocking mode by default.

  The current instance has been disposed. 0 1.0.5000.0 2.0.0.0
- Method
  System.Void

  Closes the current instance and releases all managed and unmanaged resources allocated by the current instance.

  This method calls the () method with the argument set to , which frees both managed and unmanaged resources used by the current instance.

  The socket attempts to perform a graceful closure when the socket option is enabled and set to a non-zero linger time. In all other cases, closure is forced and any pending data is lost.

  0
  1.0.5000.0
  2.0.0.0
- Method
  2.0.0.0
  System.Void `` To be added. To be added. To be added.
- Method
  System.Void ``

  The associated with the socket to connect to.

  Associates the current instance with a remote endpoint.

  This method sets the property of the current instance to .

  For connection-oriented protocols, this method establishes a connection between the current instance and the socket associated with . This method is used only on the client-side. The method establishes the connection on the server-side. Once the connection has been made, data can be sent using the method, and received using the method.

  For connectionless protocols, the method can be used from both client and server-sides, allowing the use of the method instead of the method. The property is set to and the property is set to a value determined by the protocol; however, a connection is not established. Subsequent data is required to be received on the endpoint set in the property.

  is .

  An asynchronous call is pending and a blocking method has been called.

  An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  The current instance has been disposed. A caller in the call stack does not have the required permission. Requires permission to make a connection to the endpoint defined by . See . 0 1.0.5000.0 2.0.0.0
- Method
  2.0.0.0
  System.Void `` `` To be added. To be added. To be added. To be added.
- Method
  2.0.0.0
  System.Void `` `` To be added. To be added. To be added. To be added.
- Method
  2.0.0.0
  System.Void `` `` To be added. To be added. To be added. To be added.
- Method
  2.0.0.0
  System.Boolean `` To be added. To be added. To be added. To be added.
- Property
  System.Boolean

  Gets a value indicating whether the current instance is connected.

  indicates that the current instance was connected at the time of the last I/O operation; indicates that the current instance is not connected.

  This property is read-only.

  When this property returns , the current instance was connected at the time of the last I/O operation; it might not still be connected. When this property returns , the current instance was never connected or is not currently connected.

  The current instance is considered connected when the property contains a valid endpoint.

  The and methods, and their asynchronous counterparts set this property.

  0
  1.0.5000.0
  2.0.0.0
- Method
  2.0.0.0
  System.Void `` To be added. To be added. To be added.
- Method
  2.0.0.0
  System.Boolean `` To be added. To be added. To be added. To be added.
- Method
  System.Void `` A . Specify to release both managed and unmanaged resources; to release only unmanaged resources.

  Closes the current instance, releases the unmanaged resources allocated by the current instance, and optionally releases the managed resources.

  This method closes the current instance and releases all unmanaged resources allocated by the current instance. When is , this method also releases all resources held by any managed objects allocated by the current instance.

  This method closes the current instance but does not release any managed resources.

  The method can be called multiple times by other objects. When overriding this method, do not reference objects that have been previously disposed in an earlier call.

  Use this method to release resources allocated by the current instance.

  0
  1.0.5000.0
  2.0.0.0
- Property
  2.0.0.0
  System.Boolean To be added. To be added. To be added.
- Method
  2.0.0.0
  System.Net.Sockets.SocketInformation `` To be added. To be added. To be added. To be added.
- Property
  2.0.0.0
  System.Boolean To be added. To be added. To be added.
- Method
  System.Net.Sockets.Socket `` A object that holds the state information for the asynchronous operation.

  Ends an asynchronous call to accept an incoming connection request.

  A new connected instance.

  This method blocks if the asynchronous operation has not completed.

  The method completes an asynchronous request that was started with a call to the method. The object specified for the parameter is required to be the same object as was returned by the method call that began the request.

  If the method is invoked via the delegate specified to the method, the parameter is the argument passed to the delegate's method.

  is . was not returned by the current instance from a call to the method. was previously called for this operation. An error occurred during the operation.

  For additional information on causes of the , see the class.

  The current instance has been disposed.

  For an outline of an asynchronous operation, see the method. For the complete example, which uses the method, see the class overview.

  0
  1.0.5000.0
  2.0.0.0
- Method
  2.0.0.0
  System.Net.Sockets.Socket `` `` To be added. To be added. To be added. To be added. To be added.
- Method
  2.0.0.0
  System.Net.Sockets.Socket `` `` `` To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  System.Void `` A object that holds the state information for the asynchronous operation.

  Ends an asynchronous call to associate the current instance with a remote endpoint.

  This method blocks if the asynchronous operation has not completed.

  The method completes an asynchronous request that was started with a call to the method. The object specified for the parameter is required to be the same object as was returned by the method call that began the request.

  If the method is invoked via the delegate specified to the method, the parameter is the argument passed to the delegate's method.

  is . was not returned by the current instance from a call to the method. was previously called for this operation. An error occurred during the operation.

  For additional information on causes of the , see the class.

  The current instance has been disposed.

  For an outline of an asynchronous operation, see the method. For the complete example, which uses the method, see the class overview.

  0
  1.0.5000.0
  2.0.0.0
- Method
  2.0.0.0
  System.Void `` To be added. To be added. To be added.
- Method
  System.Int32 ``

  A object that holds the state information for the asynchronous operation.

  Ends an asynchronous call to receive data from a socket.

  A containing the number of bytes received.

  This method blocks if the asynchronous operation has not completed.

  The method completes an asynchronous request that was started with a call to the method. The object specified for the parameter is required to be the same object as was returned by the method call that began the request.

  If the method is invoked via the delegate specified to the method, the parameter is the argument passed to the delegate's method.

  is . was not returned by the current instance from a call to the method. was previously called for this operation. An error occurred during the operation.

  For additional information on causes of the , see the class.

  The current instance has been disposed.

  For an outline of an asynchronous operation, see the method. For the complete example, which uses the method, see the class overview.

  0
  1.0.5000.0
  2.0.0.0
- Method
  2.0.0.0
  System.Int32 `` `` To be added. To be added. To be added. To be added. To be added.
- Method
  System.Int32 `` `` To be added. To be added.

  Ends an asynchronous call to receive data from a socket and store the endpoint associated with the socket that sent the data.

  A containing the number of bytes received.

  This method blocks if the asynchronous operation has not completed.

  The method completes an asynchronous request that was started with a call to the method. The object specified for the parameter is required to be the same object as was returned by the method call that began the request.

  If the method is invoked via the delegate specified to the method, the parameter is the argument passed to the delegate's method.

  is . was not returned by the current instance from a call to the method. was previously called for this operation. An error occurred during the operation.

  For additional information on causes of the , see the class.

  The current instance has been disposed.

  For an outline of an asynchronous operation, see the method. For the complete example, see the class overview.

  0
  1.0.5000.0
  2.0.0.0
- Method
  2.0.0.0
  System.Int32 `` `` `` `` To be added. To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  System.Int32 ``

  A object that holds the state information for the asynchronous operation.

  Ends an asynchronous call to send data to a connected socket.

  A containing the number of bytes sent.

  This method blocks if the asynchronous operation has not completed.

  The method completes an asynchronous request that was started with a call to the method. The object specified for the parameter is required to be the same object as was returned by the method call that began the request.

  If the method is invoked via the delegate specified to the method, the parameter is the argument passed to the delegate's method.

  is . was not returned by the current instance from a call to the method. was previously called for this operation. An error occurred during the operation.

  For additional information on causes of the , see the class.

  The current instance has been disposed.

  For an outline of an asynchronous operation, see the method. For the complete example, which uses the method, see the class overview.

  0
  1.0.5000.0
  2.0.0.0
- Method
  2.0.0.0
  System.Int32 `` `` To be added. To be added. To be added. To be added. To be added.
- Method
  2.0.0.0
  System.Void `` To be added. To be added. To be added.
- Method
  System.Int32 ``

  A object that holds the state information for the asynchronous operation.

  Ends an asynchronous call to send data to a socket associated with a specified endpoint.

  A containing the number of bytes sent.

  This method blocks if the asynchronous operation has not completed.

  The method completes an asynchronous request that was started with a call to the method. The object specified for the parameter is required to be the same object as was returned by the method call that began the request.

  If the method is invoked via the delegate specified to the method, the parameter is the argument passed to the delegate's method.

  is . was not returned by the current instance from a call to the method. was previously called for this operation. An error occurred during the operation.

  For additional information on causes of the , see the class.

  The current instance has been disposed.

  For an outline of an asynchronous operation, see the method. For the complete example, see the class overview.

  0
  1.0.5000.0
  2.0.0.0
- Property
  2.0.0.0
  System.Boolean To be added. To be added. To be added.
- Method
  System.Void

  Closes the current instance and releases unmanaged resources allocated by the current instance.

  Application code does not call this method; it is automatically invoked during garbage collection unless finalization by the garbage collector has been disabled. For more information, see , and .

  This method calls () to free unmanaged resources used by the current instance.

  This method overrides .

  0
  1.0.5000.0
  2.0.0.0
- Method
  System.Int32

  Generates a hash code for the current instance.

  A containing the hash code for the current instance.

  The algorithm used to generate the hash code is unspecified.

  This method overrides .

  0
  1.0.5000.0
- Method
  System.Object `` `` To be added. To be added.

  Retrieves an object containing the value of the specified socket option.

  The following table describes the values returned by this method.

  optionName
  Return value
  An instance of the class.

  -or-

  An instance of the class.
  All other values defined in the enumeration.
  A containing the value of the option.

  Socket options determine the behavior of the current instance.

  and are not independent. See the (, , ) method for a listing of the values of the enumeration grouped by .

  An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  The current instance has been disposed.

  The following example gets the state of the linger option and the size of the receive buffer, changes the values of both, then gets the new values.

  `using System; using System.Net.Sockets; class OptionTest{ public static void Main() { // Get the current option values. Socket someSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); LingerOption lingerOp = (LingerOption)someSocket.GetSocketOption( SocketOptionLevel.Socket, SocketOptionName.Linger); int receiveBuffer = (int)someSocket.GetSocketOption( SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer); Console.WriteLine( "Linger option is {0} and set to {1} seconds.", lingerOp.Enabled.ToString(), lingerOp.LingerTime.ToString() ); Console.WriteLine( "Size of the receive buffer is {0} bytes.", receiveBuffer.ToString() ); // Change the options. lingerOp = new LingerOption(true, 10); someSocket.SetSocketOption( SocketOptionLevel.Socket, SocketOptionName.Linger, lingerOp); someSocket.SetSocketOption( SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, 2048); Console.WriteLine( "The SetSocketOption method has been called."); // Get the new option values. lingerOp = (LingerOption)someSocket.GetSocketOption( SocketOptionLevel.Socket, SocketOptionName.Linger); receiveBuffer = (int)someSocket.GetSocketOption( SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer); Console.WriteLine( "Linger option is now {0} and set to {1} seconds.", lingerOp.Enabled.ToString(), lingerOp.LingerTime.ToString()); Console.WriteLine( "Size of the receive buffer is now {0} bytes.", receiveBuffer.ToString()); } }`

  The output is

  Linger option is False and set to 0 seconds.

  Size of the receive buffer is 8192 bytes.

  The SetSocketOption method has been called.

  Linger option is now True and set to 10 seconds.

  Size of the receive buffer is now 2048 bytes.

  0
  1.0.5000.0
  2.0.0.0
- Method
  System.Void `` `` `` To be added. To be added. To be added.

  Retrieves the value of the specified socket option.

  Socket options determine the behavior of the current instance.

  Upon successful completion, the array specified by the parameter contains the value of the specified socket option.

  When the length of the array is smaller than the number of bytes required to store the value of the specified socket option, a exception is thrown.

  is too small to store the value of the specified socket option.

  -or-

  An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  The current instance has been disposed. 0 1.0.5000.0 2.0.0.0
- Method
  System.Byte[] `` `` `` To be added. To be added. To be added.

  Retrieves the value of the specified socket option.

  A array containing the value of the specified socket option.

  Socket options determine the behavior of the current instance.

  The parameter is used to allocate an array to store the value of the specified option. When this value is smaller than the number of bytes required to store the value of the specified option, a exception is thrown. When this value is greater than or equal to the number of bytes required to store the value of the specified option, the array returned by this method is allocated to be exactly the required length.

  is smaller than the number of bytes required to store the value of the specified socket option.

  -or-

  An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  The current instance has been disposed. 0 1.0.5000.0 2.0.0.0
- Property
  System.IntPtr

  Gets the operating system handle for the current instance.

  A containing the operating system handle for the current instance.

  This property is read-only.

  Requires permission to access unmanaged code. See . 1 RuntimeInfrastructure 1.0.5000.0 2.0.0.0
- Method
  System.Int32 `` `` `` To be added. To be added. To be added.

  Provides low-level access to the socket, the transport protocol, or the communications subsystem.

  A containing the length of the array after the method returns.

  If an attempt is made to change the blocking mode of the current instance, an exception is thrown. Use the property to change the blocking mode.

  The control codes and their requirements are implementation defined. Do not use this method if platform independence is a requirement.

  Input data is not required for all control codes. Output data is not supplied by all control codes and, if not supplied, the return value is 0.

  An attempt was made to change the blocking mode.

  Use the property to change the blocking mode.

  An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  The current instance has been disposed. Requires permission to access unmanaged code. See .

  The following example gets the number of bytes of available data to be read and writes the result to the console on a Windows system. The remote endpoint (remoteEndpoint) to connect to might need to be changed to a value that is valid on the current system.

  `using System; using System.Net; using System.Net.Sockets; class App { static void Main() { IPAddress remoteAddress = Dns.Resolve(Dns.GetHostName()).AddressList[0]; IPEndPoint remoteEndpoint = new IPEndPoint(remoteAddress, 80); Socket someSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); someSocket.Connect(remoteEndpoint); int fionRead = 0x4004667F; byte[]inValue = {0x00, 0x00, 0x00, 0x00}; byte[]outValue = {0x00, 0x00, 0x00, 0x00}; someSocket.IOControl(fionRead, inValue, outValue); uint bytesAvail = BitConverter.ToUInt32(outValue, 0); Console.WriteLine( "There are {0} bytes available to be read.", bytesAvail.ToString() ); } }`

  The output is

  There are 0 bytes available to be read.

  A caller in the call stack does not have the required permissions. 0 1.0.5000.0 2.0.0.0
- Method
  2.0.0.0
  System.Int32 `` `` `` To be added. To be added. To be added. To be added. To be added. To be added.
- Property
  2.0.0.0
  System.Boolean To be added. To be added. To be added.
- Property
  2.0.0.0
  System.Net.Sockets.LingerOption To be added. To be added. To be added.
- Method
  System.Void `` A containing the maximum length of the queue of pending connections.

  Places the current instance into the listening state where it waits for incoming connection requests.

  Once this method is called, incoming connection requests are placed in a queue. The maximum size of the queue is specified by the parameter. The size of the queue is limited to legal values by the underlying protocol. Illegal values of the parameter are replaced with a legal value, which is implementation defined.

  If a connection request arrives and the queue is full, a is thrown on the client.

  A socket in the listening state has no remote endpoint associated with it. Attempting to access the property throws a exception.

  This method is ignored if called more than once on the current instance.

  This method is used only on the server-side of connection-oriented protocols. Call the method before this method is called the first time. Call the method before the first call to the method.

  The property of the current instance is true.

  -or-

  has not been called on the current instance.

  -or-

  An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  The current instance has been disposed. 0 1.0.5000.0 2.0.0.0
- Property
  System.Net.EndPoint

  Gets the local endpoint associated with the current instance.

  The local associated with the current instance.

  This property is read-only.

  This property contains the network connection information for the current instance.

  The and methods, and their asynchronous counterparts set this property. If not previously set, the and methods, and their asynchronous counterparts set this property.

  An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  The current instance has been disposed. 0 1.0.5000.0 2.0.0.0
- Property
  2.0.0.0
  System.Boolean To be added. To be added. To be added.
- Property
  2.0.0.0
  System.Boolean To be added. To be added. To be added.
- Property
  2.0.0.0
  System.Boolean To be added. To be added. To be added.
- Method
  System.Boolean `` `` To be added. One of the values defined in the enumeration.

  Determines the read, write, or error status of the current instance.

  A where indicates the current instance satisfies at least one of the conditions in the following table corresponding to the specified value; otherwise, . is returned if the status of the current instance cannot be determined within the time specified by .

  SelectMode value
  Condition
  SelectRead

  Data is available for reading (includes out-of-band data if the value defined in the enumeration is set).

  -or-

  The socket is in the listening state with a pending connection, and the method has been called and is guaranteed to succeed without blocking.

  -or-

  The connection has been closed, reset, or terminated.

  SelectWrite

  Data can be sent.

  -or-

  A non-blocking method is being processed and the connection has succeeded.

  SelectError

  The value defined in the enumeration is not set and out-of-band data is available.

  -or-

  A non-blocking method is being processed and the connection has failed.

  To be added. is not one of the values defined in the enumeration.

  An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  The current instance has been disposed. 0 1.0.5000.0 2.0.0.0
- Property
  System.Net.Sockets.ProtocolType

  Gets the protocol type of the current instance.

  One of the values defined in the enumeration.

  This property is read-only.

  This property is set by the constructor for the current instance. The value of this property specifies the protocol used by the current instance.

  0
  1.0.5000.0
  2.0.0.0
- Method
  System.Int32 `` A array to store data received from the socket.

  Receives data from a socket.

  A containing the number of bytes received.

  This method is equivalent to (, 0, .Length, ).

  is .

  An asynchronous call is pending and a blocking method has been called.

  An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  A caller in the call stack does not have the required permissions. The current instance has been disposed. Requires permission to accept connections. See . 0 1.0.5000.0 2.0.0.0
- Method
  2.0.0.0
  System.Int32 `` To be added. To be added. To be added. To be added.
- Method
  System.Int32 `` `` To be added. To be added.

  Receives data from a socket.

  A containing the number of bytes received.

  This method is equivalent to (, 0, .Length, ).

  is .

  An asynchronous call is pending and a blocking method has been called.

  is not a valid combination of values.

  -or-

  An error occurred while accessing the socket.

  For additional information on causes of the , see the class. A caller in the call stack does not have the required permissions. The current instance has been disposed. Requires permission to accept connections. See . 0 1.0.5000.0 2.0.0.0
- Method
  2.0.0.0
  System.CLSCompliant(false)
  System.Int32 `` `` To be added. To be added. To be added. To be added. To be added.
- Method
  System.Int32 `` `` `` To be added. A containing the number of bytes to receive. To be added.

  Receives data from a socket.

  A containing the number of bytes received.

  This method is equivalent to (, 0, , ).

  is .

  < 0.

  -or-

  > .Length.

  An asynchronous call is pending and a blocking method has been called.

  is not a valid combination of values.

  -or-

  An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  A caller in the call stack does not have the required permissions. The current instance has been disposed. Requires permission to accept connections. See . 0 1.0.5000.0 2.0.0.0
- Method
  2.0.0.0
  System.CLSCompliant(false)
  System.Int32 `` `` `` To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  System.Int32 `` `` `` `` To be added. A containing the zero-based position in to begin storing the received data. A containing the number of bytes to receive. To be added.

  Receives data from a socket.

  A containing the number of bytes received.

  The property is required to be set before this method is called.

  The property of the socket determines the behavior of this method when no incoming data is available. When , the exception is thrown. When , this method blocks and waits for data to arrive.

  For socket types, if the remote socket was shut down gracefully, and all data was received, this method immediately returns zero, regardless of the blocking state.

  For message-oriented sockets, if the message is larger than the size of , the buffer is filled with the first part of the message, and the exception is thrown. For unreliable protocols, the excess data is lost; for reliable protocols, the data is retained by the service provider.

  When the flag is specified as part of the parameter and the socket is configured for in-line reception of out-of-band (OOB) data (using the socket option) and OOB data is available, only OOB data is returned.

  When the flag is specified as part of the parameter, available data is copied into but is not removed from the system buffer.

  is .

  < 0.

  -or-

  > .Length.

  -or-

  < 0.

  -or-

  > .Length - .

  An asynchronous call is pending and a blocking method has been called.

  is not a valid combination of values.

  -or-

  The property was not set.

  -or-

  An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  A caller in the call stack does not have the required permissions. The current instance has been disposed.

  Requires permission to accept a connection on the endpoint defined by the property of the current instance. See .

  0
  1.0.5000.0
  2.0.0.0
- Method
  2.0.0.0
  System.Int32 `` `` `` `` `` To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  2.0.0.0
  System.Boolean `` To be added. To be added. To be added. To be added.
- Property
  2.0.0.0
  System.Int32 To be added. To be added. To be added.
- Method
  System.Int32 `` `` To be added. To be added.

  Receives data from a socket and, for connectionless protocols, stores the endpoint associated with the socket that sent the data.

  A containing the number of bytes received.

  This method is equivalent to (, 0, .Length, , ).

  or is .

  An asynchronous call is pending and a blocking method has been called.

  An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  The current instance has been disposed. Requires permission to accept connections from the endpoint defined by . See . 0 1.0.5000.0 2.0.0.0
- Method
  System.Int32 `` `` `` To be added. To be added. To be added.

  Receives data from a socket and, for connectionless protocols, stores the endpoint associated with the socket that sent the data.

  A containing the number of bytes received.

  This method is equivalent to (, 0, .Length, , ).

  or is .

  An asynchronous call is pending and a blocking method has been called.

  specified an invalid value.

  -or-

  An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  A caller in the call stack does not have the required permissions. The current instance has been disposed. Requires permission to accept connections from the endpoint defined by . See . 0 1.0.5000.0 2.0.0.0
- Method
  System.Int32 `` `` `` `` To be added. A containing the number of bytes to receive. To be added. To be added.

  Receives data from a socket and, for connectionless protocols, stores the endpoint associated with the socket that sent the data.

  A containing the number of bytes received.

  This method is equivalent to (, 0, , , ).

  or is .

  < 0.

  -or-

  > .Length.

  An asynchronous call is pending and a blocking method has been called.

  is not a valid combination of values.

  -or-

  An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  A caller in the call stack does not have the required permissions. The current instance has been disposed. Requires permission to accept connections from the endpoint defined by . See . 0 1.0.5000.0 2.0.0.0
- Method
  System.Int32 `` `` `` `` `` To be added. A containing the zero-based position in to begin storing the received data. A containing the number of bytes to receive. To be added. To be added.

  Receives data from a socket and, for connectionless protocols, stores the endpoint associated with the socket that sent the data.

  A containing the number of bytes received.

  For connectionless protocols, when this method successfully completes, contains the endpoint associated with the socket that sent the data.

  For connection-oriented protocols, is left unchanged.

  The property is required to be set before this method is called or a is thrown.

  The property of the socket determines the behavior of this method when no incoming data is available. When , the exception is thrown. When , this method blocks and waits for data to arrive.

  For socket types, if the remote socket was shut down gracefully, and all data was received, this method immediately returns zero, regardless of the blocking state.

  For message-oriented sockets, if the message is larger than the size of , the buffer is filled with the first part of the message, and the exception is thrown. For unreliable protocols, the excess data is lost; for reliable protocols, the data is retained by the service provider.

  When the flag is specified as part of theparameter and the socket is configured for in-line reception of out-of-band (OOB) data (using the socket option) and OOB data is available, only OOB data is returned.

  When the flag is specified as part of the parameter, available data is copied into but is not removed from the system buffer.

  or is .

  < 0.

  -or-

  > .Length.

  -or-

  < 0.

  -or-

  > .Length - .

  An asynchronous call is pending and a blocking method has been called.

  is not a valid combination of values.

  -or-

  The property was not set.

  -or-

  An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  A caller in the call stack does not have the required permissions. The current instance has been disposed.

  Requires permission to accept a connection on the endpoint defined by the property of the current instance. See .

  Requires permission to make a connection to the endpoint defined by . See .

  0
  1.0.5000.0
  2.0.0.0
- Method
  2.0.0.0
  System.Boolean `` To be added. To be added. To be added. To be added.
- Method
  2.0.0.0
  System.Int32 `` `` `` `` `` `` To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  2.0.0.0
  System.Boolean `` To be added. To be added. To be added. To be added.
- Property
  2.0.0.0
  System.Int32 To be added. To be added. To be added.
- Property
  System.Net.EndPoint

  Gets the remote endpoint associated with the current instance.

  The remote associated with the current instance.

  This property is read-only.

  This property contains the network connection information associated with the socket communicating with the current instance.

  There is no remote endpoint associated with a socket in the listening state. An attempt to access the property causes a exception to be thrown.

  The and methods, and their asynchronous counterparts set this property.

  An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  The current instance has been disposed. 0 1.0.5000.0 2.0.0.0
- Method
  System.Void `` `` `` `` A object containing the instances to check for read status. A object containing the instances to check for write status. A object containing the instances to check for error status. A that specifies the time to wait for a response, in microseconds. Specify a negative value to wait indefinitely for the status to be determined.

  Determines the read, write, or error status of a set of instances.

  Upon successful completion, this method removes all instances from the specified list that do not satisfy one of the conditions associated with that list. The following table describes the conditions for each list.

  List
  Condition to remain in list

  Data is available for reading (includes out-of-band data if the value defined in the enumeration is set).

  -or-

  The socket is in the listening state with a pending connection, and the method has been called and is guaranteed to succeed without blocking.

  -or-

  The connection has been closed, reset, or terminated.

  Data can be sent.

  -or-

  A non-blocking method is being processed and the connection has succeeded.

  The value defined in the enumeration is not set and out-of-band data is available.

  -or-

  A non-blocking method is being processed and the connection has failed.

  To determine the status of a specific instance, check whether the instance remains in the list after the method returns.

  When the method cannot determine the status of all the instances within the time specified in the parameter, the method removes all the instances from all the lists and returns.

  At least one of , , or , is required to contain at least one instance. The other parameters can be empty or .

  All of the following parameters are or empty: , , and . An error occurred while accessing one of the sockets.

  For additional information on causes of the , see the class.

  The following example determines the status of the socket instance named socket3 and writes the result to the console.

  `using System; using System.Collections; using System.Net.Sockets; class SelectTest { public static void Main() { Socket socket1 = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); Socket socket2 = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); Socket socket3 = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); ArrayList readList = new ArrayList(); ArrayList writeList = new ArrayList(); ArrayList errorList = new ArrayList(); readList.Add(socket1); readList.Add(socket2); readList.Add(socket3); errorList.Add(socket1); errorList.Add(socket3); // readList.Contains(Socket3) returns true // if Socket3 is in ReadList. Console.WriteLine( "socket3 is placed in readList and errorList."); Console.WriteLine( "socket3 is {0}in readList.", readList.Contains(socket3) ? "" : "not " ); Console.WriteLine( "socket3 is {0}in writeList.", writeList.Contains(socket3) ? "" : "not " ); Console.WriteLine( "socket3 is {0}in errorList.", errorList.Contains(socket3) ? "" : "not " ); Socket.Select(readList, writeList, errorList, 10); Console.WriteLine("The Select method has been called."); Console.WriteLine( "socket3 is {0}in readList.", readList.Contains(socket3) ? "" : "not " ); Console.WriteLine( "socket3 is {0}in writeList.", writeList.Contains(socket3) ? "" : "not " ); Console.WriteLine( "socket3 is {0}in errorList.", errorList.Contains(socket3) ? "" : "not " ); } }`

  The output is

  socket3 is placed in readList and errorList.

  socket3 is in readList.

  socket3 is not in writeList.

  socket3 is in errorList.

  The Select method has been called.

  socket3 is not in readList.

  socket3 is not in writeList.

  socket3 is not in errorList.

  0
  1.0.5000.0
  2.0.0.0
- Method
  System.Int32 `` A array containing data to send to the socket.

  Sends data to a connected socket.

  A containing the number of bytes sent.

  This method is equivalent to (, 0, .Length, ).

  is .

  An asynchronous call is pending and a blocking method has been called.

  An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  The current instance has been disposed. 0 1.0.5000.0 2.0.0.0
- Method
  2.0.0.0
  System.Int32 `` To be added. To be added. To be added. To be added.
- Method
  System.Int32 `` `` To be added. To be added.

  Sends data to a connected socket.

  A containing the number of bytes sent.

  This method is equivalent to (, 0, .Length, ).

  is .

  An asynchronous call is pending and a blocking method has been called.

  is not a valid combination of values.

  -or-

  An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  The current instance has been disposed. 0 1.0.5000.0 2.0.0.0
- Method
  2.0.0.0
  System.Int32 `` `` To be added. To be added. To be added. To be added. To be added.
- Method
  System.Int32 `` `` `` To be added. A containing the number of bytes to send. To be added.

  Sends data to a connected socket.

  A containing the number of bytes sent.

  This method is equivalent to (, 0, , ).

  is .

  < 0.

  -or-

  > .Length.

  An asynchronous call is pending and a blocking method has been called.

  is not a valid combination of values.

  -or-

  An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  The current instance has been disposed. 0 1.0.5000.0 2.0.0.0
- Method
  2.0.0.0
  System.CLSCompliant(false)
  System.Int32 `` `` `` To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  System.Int32 `` `` `` `` To be added. A that specifies the zero-based position in buffer that is the starting location of the data to send. A containing the number of bytes to send. To be added.

  Sends data to a connected socket.

  A containing the number of bytes sent.

  For connection-oriented protocols, the property of the current instance is required to be set before calling this method.

  For connectionless protocols, calling the methods sets the property and allows the method to be used instead of the method.

  When the flag is specified as part of the parameter, the sent data is not routed.

  When the flag is specified as part of the parameter, only out-of-band (OOB) data is sent.

  When the property of the current instance is set to and buffer space is not available within the underlying protocol, this method blocks.

  For message-oriented sockets, when is greater than the maximum message size of the underlying protocol, no data is sent and the exception is thrown.

  is .

  < 0.

  -or-

  > .Length.

  -or-

  < 0.

  -or-

  > .Length - .

  An asynchronous call is pending and a blocking method has been called.

  is not a valid combination of values.

  -or-

  An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  The current instance has been disposed. 0 1.0.5000.0 2.0.0.0
- Method
  2.0.0.0
  System.Int32 `` `` `` `` `` To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  2.0.0.0
  System.Boolean `` To be added. To be added. To be added. To be added.
- Property
  2.0.0.0
  System.Int32 To be added. To be added. To be added.
- Method
  2.0.0.0
  System.Void `` To be added. To be added. To be added.
- Method
  2.0.0.0
  System.Void `` `` `` `` To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  2.0.0.0
  System.Boolean `` To be added. To be added. To be added. To be added.
- Property
  2.0.0.0
  System.Int32 To be added. To be added. To be added.
- Method
  System.Int32 `` `` A array containing data to send to the socket. To be added.

  Sends data to the socket associated with the specified endpoint.

  A containing the number of bytes sent.

  This method is equivalent to (, 0, .Length, ,).

  is .

  An asynchronous call is pending and a blocking method has been called.

  An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  A caller in the call stack does not have the required permissions. The current instance has been disposed. Requires permission to make a connection to the endpoint defined by . See . 0 1.0.5000.0 2.0.0.0
- Method
  System.Int32 `` `` `` A array containing data to send to the socket. To be added. To be added.

  Sends data to the socket associated with the specified endpoint.

  A containing the number of bytes sent.

  This method is equivalent to (, 0, .Length, , ).

  is .

  An asynchronous call is pending and a blocking method has been called.

  is not a valid combination of values.

  -or-

  An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  A caller in the call stack does not have the required permissions. The current instance has been disposed. Requires permission to make a connection to the endpoint defined by . See . 0 1.0.5000.0 2.0.0.0
- Method
  System.Int32 `` `` `` `` A array containing data to send to the socket. A containing the number of bytes to send. To be added. To be added.

  Sends data to the socket associated with the specified endpoint.

  A containing the number of bytes sent.

  This method is equivalent to (, 0, , , ).

  is .

  < 0.

  -or-

  > .Length.

  An asynchronous call is pending and a blocking method has been called.

  is not a valid combination of values.

  -or-

  An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  A caller in the call stack does not have the required permissions. The current instance has been disposed. Requires permission to make a connection to the endpoint defined by . See . 0 1.0.5000.0 2.0.0.0
- Method
  System.Int32 `` `` `` `` `` A array containing data to send to the socket. A that specifies the zero-based position in buffer that is the starting location of the data to send. A containing the number of bytes to send. To be added. To be added.

  Sends data to the socket associated with the specified endpoint.

  A containing the number of bytes sent.

  For connected sockets using connectionless protocols, overrides the endpoint specified in the property.

  For unconnected sockets using connectionless protocols, this method sets the property of the current instance to a value determined by the protocol. Subsequent data is required to be received on .

  When the flag is specified as part of the parameter, the sent data is not routed.

  When the flag is specified as part of the parameter, only out-of-band (OOB) data is sent.

  When the property of the current instance is set to and buffer space is not available within the underlying protocol, this method blocks.

  For message-oriented sockets, when is greater than the maximum message size of the underlying protocol, no data is sent and the exception is thrown.

  For connection-oriented sockets, the parameter is ignored.

  is .

  < 0.

  -or-

  > .Length.

  -or-

  < 0.

  -or-

  > .Length - .

  An asynchronous call is pending and a blocking method has been called.

  is not a valid combination of values.

  -or-

  An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  A caller in the call stack does not have the required permissions. The current instance has been disposed. Requires permission to make a connection to the endpoint defined by . See . 0 1.0.5000.0 2.0.0.0
- Method
  2.0.0.0
  System.Boolean `` To be added. To be added. To be added. To be added.
- Method
  2.0.0.0
  System.Void `` `` `` To be added. To be added. To be added. To be added. To be added.
- Method
  System.Void `` `` `` To be added. To be added. To be added.

  Sets socket options with values of type .

  Socket options determine the behavior of the current instance. Multiple options can be set on the current instance by calling this method multiple times.

  For socket options with values of type or , see the (, , ) version of this method.

  For the , , or socket options, see the (, , ) version of this method.

  An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  A caller in the call stack does not have the required permissions. The current instance has been disposed. Requires permission to access unmanaged code. See . 0 1.0.5000.0 2.0.0.0
- Method
  System.Void `` `` `` To be added. To be added. To be added.

  Sets socket options with values of type and .

  Socket options determine the behavior of the current instance. Multiple options can be set on the current instance by calling this method multiple times.

  For a socket option with a data type, specify a non-zero to enable the option, and an equal to zero to disable the option.

  Socket options are grouped by level of protocol support. The following tables list the members of the enumeration supported by each member of the enumeration. Only members that have associated values of the and data types are listed.

  The following table lists the members of the enumeration supported by the member of the enumeration. Options that do not require permission to access unmanaged code are noted.
  SocketOptionName
  Description
  Broadcast
  A where indicates broadcast messages are allowed to be sent to the socket.
  Debug
  A where indicates to record debugging information.
  DontLinger
  A where indicates to close the socket without lingering. This option does not require permission to access unmanaged code.
  DontRoute
  A where indicates not to route data.
  Error
  A that contains the error code associated with the last socket error. The error code is cleared by this option. This option is read-only.
  KeepAlive
  A where (the default) indicates to enable keep-alives, which allows a connection to remain open after a request has completed. This option does not require permission to access unmanaged code.
  OutOfBandInline
  A where indicates to receive out-of-band data in the normal data stream.
  ReceiveBuffer
  A that specifies the total per-socket buffer space reserved for receives. This option does not require permission to access unmanaged code.
  ReceiveTimeout
  A that specifies the maximum time, in milliseconds, the and methods will block when attempting to receive data. If data is not received within this time, a exception is thrown. This option does not require permission to access unmanaged code.
  ReuseAddress
  A where allows the socket to be bound to an address that is already in use.
  SendBuffer
  A that specifies the total per-socket buffer space reserved for sends. This option does not require permission to access unmanaged code.
  SendTimeout
  A that specifies the maximum time, in milliseconds, the and methods will block when attempting to send data. If data is not sent within this time, a exception is thrown. This option does not require permission to access unmanaged code.
  Type

  One of the values defined in the enumeration. This option is read-only.

  The following table lists the members of the enumeration supported by the member of the enumeration. These options require permission to access unmanaged code.

  SocketOptionName
  Description
  HeaderIncluded
  A where indicates the application is providing the IP header for outgoing datagrams.
  IPOptions
  A array that specifies IP options to be inserted into outgoing datagrams.
  IpTimeToLive
  A that specifies the time-to-live for datagrams. The time-to-live designates the number of networks on which the datagram is allowed to travel before being discarded by a router.
  MulticastInterface
  A array that specifies the interface for outgoing multicast packets.
  MulticastLoopback
  A where enables multicast loopback.
  MulticastTimeToLive
  A that specifies the time-to-live for multicast datagrams.
  TypeOfService
  A that specifies the type of service field in the IP header.
  UseLoopback
  A where indicates to send a copy of the data back to the sender.

  The following table lists the members of the enumeration supported by the member of the enumeration. These options do not require permission to access unmanaged code.

  SocketOptionName
  Description
BsdUrgent
A where indicates to use urgent data as defined by IETF RFC 1222. Once enabled, this option cannot be disabled.
Expedited
A where indicates to use expedited data as defined by IETF RFC 1222. Once enabled, this option cannot be disabled.
NoDelay
A where indicates to disable the Nagle algorithm for send coalescing.

The following table lists the members of the enumeration supported by the member of the enumeration. These options do not require permission to access unmanaged code.

SocketOptionName
Description
ChecksumCoverage
A that specifies UDP checksum coverage.
NoChecksum
A where indicates to send UDP datagrams with the checksum set to zero.

For the , , and members of the enumeration, see the (, , ) version of this method.

An error occurred while accessing the socket.

For additional information on causes of the , see the class.

A caller in the call stack does not have the required permissions. The current instance has been disposed. Some options require permission to access unmanaged code. All the options that do not require permission are noted in the tables in the Description section. All options not so noted require this permission. See . 0 1.0.5000.0 2.0.0.0
- Method
  System.Void `` `` `` To be added. To be added. To be added.

  Sets the , , or socket options.

  Socket options determine the behavior of the current instance. Multiple options can be set on the current instance by calling this method multiple times.

  The following table summarizes the valid combinations of input parameters.

  optionLevel/optionName
  optionValue
  /
  An instance of the class.

  /

  - or -

  /

  An instance of the class.

  When setting the option, a exception is thrown if the property of the instance is less than zero or greater than .

  For more information on the option, see the class and the method.

  For more information on the and options, see the class.

  For socket options with values of type or , see the (, , ) version of this method.

  , , or specified an invalid value. is . An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  A caller in the call stack does not have the required permissions. The current instance has been disposed. The and options require permission to access unmanaged code. See . 0 1.0.5000.0 2.0.0.0
- Method
  System.Void `` One of the values defined in the enumeration.

  Terminates the ability to send or receive data on a connected socket.

  When is set to , the socket on the other end of the connection is notified that the current instance will not send any more data. If the method is subsequently called, a

  exception is thrown.

  When is set to , the socket on the other end of the connection is notified that the current instance will not receive any more data. After all the data currently queued on the current instance is received, any subsequent calls to the method cause a exception to be thrown.

  Setting to terminates both sends and receives as described above. Once this occurs, the socket cannot be used.

  To free resources allocated by the current instance, call the method.

  Expected common usage is for the method to be called before the method to ensure that all pending data is sent or received.

  An error occurred while accessing the socket.

  For additional information on causes of the , see the class.

  The current instance has been disposed. 0 1.0.5000.0 2.0.0.0
- Property
  System.Net.Sockets.SocketType

  Gets the socket type of the current instance.

  One of the values defined in the enumeration.

  This property is read-only.

  This property is set by the constructor for the current instance.

  0
  1.0.5000.0
  2.0.0.0
- Property
  System.Boolean To be added. To be added. To be added. 1.0.5000.0 2.0.0.0
- Property
  System.Boolean To be added. To be added. To be added. 1.0.5000.0 2.0.0.0 System.Obsolete("Use OSSupportsIPv6 instead")
- Method
  System.Void Implemented to support the interface. [Note: For more information, see .] To be added. 0 1.0.5000.0 2.0.0.0
- Property
  2.0.0.0
  System.Int16 To be added. To be added. To be added.
- Property
  2.0.0.0
  System.Boolean To be added. To be added. To be added.
0