Share via


Poll Method

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Determines the status of the Socket.

Namespace:  System.Net.Sockets
Assembly:  System (in System.dll)

Syntax

'Declaration
Public Function Poll ( _
    microSeconds As Integer, _
    mode As SelectMode _
) As Boolean
public bool Poll(
    int microSeconds,
    SelectMode mode
)
public:
bool Poll(
    int microSeconds, 
    SelectMode mode
)
member Poll : 
        microSeconds:int * 
        mode:SelectMode -> bool 
public function Poll(
    microSeconds : int, 
    mode : SelectMode
) : boolean

Parameters

Return Value

Type: System. . :: . .Boolean
The status of the Socket based on the polling mode value passed in the mode parameter.

Mode

Return Value

SelectRead

true if Listen has been called and a connection is pending;

-or-

true if data is available for reading;

-or-

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

otherwise, returns false.

SelectWrite

true , if processing a Connect, and the connection has succeeded;

-or-

true if data can be sent;

otherwise, returns false.

SelectError

true if processing a Connect that does not block, and the connection has failed;

-or-

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

otherwise, returns false.

Remarks

The Poll method will check the state of the Socket. Specify SelectMode..::..SelectRead for the selectMode parameter to determine if the Socket is readable. Specify SelectMode..::..SelectWrite to determine if the Socket is writable. Use SelectMode..::..SelectError to detect an error condition. Poll 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 Select method.

Note

If you receive a 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.

.NET Framework Security

See Also

Reference

Socket Class

System.Net.Sockets Namespace