socket_object.Blocking Property

Gets or sets the blocking I/O mode for a Socket.

socket_object.Blocking= <boolean_value>
-or-
...socket_object.Blocking

Prerequisites

The Socket must be open in order to set this flag.

Parameters

None

Remarks

This property sets or gets the state of the blocking mode for a Socket. If the Socket is in blocking mode, calls to receive data wait until data is available, and calls to send data wait if the output queue is full. If the Socket is not in blocking mode, calls to send or receive data throw an Exception if they would have to wait. By default Sockets are created in blocking mode. Non-blocking mode may be used to poll for data to read by repeatedly issuing receive requests and handling the Exception. A better solution is to use the Available property or to set the ReceiveTimeout or SendTimeout property for the Socket.

Examples

ts.Blocking = 0           ' Set to non-blocking mode
While ts.Available = 0 ' Test if anything to receive
Thread.Sleep(1000) ' Wait 1 second
End While
ts.Receive(recv, 1500) ' Receive the data

See Also

Networking Classes | socket_object.ReceiveTimeout | socket_object.SendTimeout