System.Net.Sockets.Socket.Poll Method

Determines the status of the System.Net.Sockets.Socket.


public bool Poll (int time_us, SelectMode mode)


Documentation for this section has not yet been entered.
One of the System.Net.Sockets.SelectMode values.


The status of the System.Net.Sockets.Socket based on the polling mode value passed in the mode parameter.


true if Socket.Listen(int) has been called and a connection is pending;


true if data is available for reading;


true if the connection has been closed, reset, or terminated;

otherwise, returns false.


true, if processing a Socket.Connect(System.Net.EndPoint), and the connection has succeeded;


true if data can be sent;

otherwise, returns false.


true if processing a Socket.Connect(System.Net.EndPoint) that does not block, and the connection has failed;


true if SocketOptionName.OutOfBandInline is not set and out-of-band data is available;

otherwise, returns false.


NotSupportedException mode is not one of the values defined in the System.Net.Sockets.SelectMode enumeration.

An error occurred while accessing the socket.

Note: For additional information on causes of the SocketException, see the System.Net.Sockets.SocketException class.

ObjectDisposedExceptionThe current instance has been disposed.


The Socket.Poll(int, SelectMode) method will check the state of the System.Net.Sockets.Socket. Specify SelectMode.SelectRead for the selectMode parameter to determine if the System.Net.Sockets.Socket is readable. Specify SelectMode.SelectWrite to determine if the System.Net.Sockets.Socket is writable. Use SelectMode.SelectError to detect an error condition. Socket.Poll(int, SelectMode) will block execution until the specified time period, measured in microseconds, elapses. Set the microSeconds parameter to a negative integer if you would like to wait indefinitely for a response. If you want to check the status of multiple sockets, you might prefer to use the Socket.Select(IList, IList, IList, int) method.


If you receive a System.Net.Sockets.SocketException, use the SocketException.ErrorCode property to obtain the specific error code. After you have obtained this code, refer to the Windows Sockets version 2 API error code documentation in the MSDN library for a detailed description of the error.


This method cannot detect certain kinds of connection problems, such as a broken network cable, or that the remote host was shut down ungracefully. You must attempt to send or receive data to detect these kinds of errors.


This member outputs trace information when you enable network tracing in your application. For more information, see [<topic://conUsingNetworkTracing>].


Namespace: System.Net.Sockets
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0,,