Share via


Socket.Poll Method

Determines the read/write status of the current socket for a specified polling mode.

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

Syntax

 public bool Poll (
         int microSeconds,
         SelectMode mode
)

Parameters

  • microSeconds
    The amount of time, in microseconds, that you want the application to wait for a response. Set this parameter to a negative integer if you want the application to wait indefinitely for a response.
  • mode
    A value of the SelectMode enumeration that specifies the polling mode whose read/write status you want to retrieve.

Return Value

The return values for the various polling modes are listed in the following table.

Polling mode Return value
SlectRead true if:
  • The Listen method has been called and a connection is pending.
  • Data is available for reading.
  • The connection has been closed, reset, or terminated.
Otherwise, false.
SlectWrite true if:
  • A Connect method call has been processed, and the connection has succeeded.
  • Data can be sent.
Otherwise, false.
SlectError true if:
  • A Connect method call that does not block has been processed, and the connection has failed.
  • The OutOfBandInline configuration option is not set and out-of-band data is available.
Otherwise, false.

Remarks

The Poll method will check the read/write state of the socket. Specify SelectMode.SelectRead for the mode parameter to determine whether the socket is readable. Specify the SelectMode.SelectWrite mode to determine whether the socket is writable. Use the SelectMode.SelectError mode to detect an error condition.

The Poll method returns when the time period specified by the microSeconds parameter elapses. Note that Poll blocks execution of other methods until it returns.

Version Information

Available in .NET Micro Framework version 2.0, 2.5

See Also

Reference

Socket Class
Socket Members
System.Net.Sockets Namespace