read


Description:

public SocketIOStatus read (uint8[] buffer, out size_t nread, Cancellable? cancellable = null) throws Error

Attempts to read up to buffer.length bytes from this into buffer.

If some data is successfully read, read will return OK, and *nread will contain the number of bytes actually read (which may be less than buffer.length).

If this is non-blocking, and no data is available, the return value will be WOULD_BLOCK. In this case, the caller can connect to the readable signal to know when there is more data to read. (NB: You MUST read all available data off the socket first. readable is only emitted after read returns WOULD_BLOCK, and it is only emitted once. See the documentation for non_blocking.)

Parameters:

this

the socket

buffer

buffer to read into

nread

on return, the number of bytes read into buffer

cancellable

a Cancellable, or null

len

size of buffer in bytes

Returns:

a SocketIOStatus, as described above (or EOF if the socket is no longer connected, or ERROR on any other error, in which case error will also be set).