SocketTools .NET Edition

InternetServer.Read Method (Int32, Byte[], Int32)

Read data from the client socket and store it in a byte array.

[Visual Basic]
Overloads Public Function Read( _
   ByVal handle As Integer, _
   ByVal buffer As Byte(), _
   ByVal length As Integer _
) As Integer
[C#]
public int Read(
   int handle,
   byte[] buffer,
   int length
);

Parameters

handle
An integer value which specifies the handle to the client session.
buffer

A byte array that the data will be stored in.

length
An integer value which specifies the maximum number of bytes of data to read. This value cannot be larger than the size of the buffer specified by the caller.

Return Value

An integer value which specifies the number of bytes actually read from the specified client socket. A return value of zero specifies that the remote host has closed the connection and there is no more data available to be read. If an error occurs, a value of -1 is returned and the application should check the value of the LastError property to determine the cause of the failure.

Remarks

The Read method returns data that has been read from the socket, up to the number of bytes specified. If no data is available to be read, the calling thread will block until data is received from the server or the connection is closed.

See Also