Gets a value that indicates whether a
Socket
is connected to a remote host as of the last
Send
or
Receive
operation.
The
Connected
property gets the connection state of the
Socket
as of the last I/O operation. When it returns
false
, the
Socket
was either never connected, or is no longer connected.
The value of the Connected property reflects the state of the connection as of the most recent operation. If you need to determine the current state of the connection, make a nonblocking, zero-byte Send call. If the call returns successfully or throws a WAEWOULDBLOCK error code (10035), then the socket is still connected; otherwise, the socket is no longer connected.
If you call
Connect
on a User Datagram Protocol (UDP) socket, the Connected property always returns
true
; however, this action does not change the inherent connectionless nature of UDP.
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.
true if Listen 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.
Gets the amount of data that has been received from the network and is available to be read.
Remarks
If you are using a non-blocking
Socket
, Available is a good way to determine whether data is queued for reading, before calling
Receive
. The available data is the total amount of data queued in the network buffer for reading. If no data is queued in the network buffer, Available returns 0.
If the remote host shuts down or closes the connection, Available can throw a
SocketException
. 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.
true if processing a Connect that does not block, and the connection has failed;
true if OutOfBandInline is not set and out-of-band data is available;
otherwise, returns false.