Socket.read

Attempts to read up to @len bytes from @sock into @buffer. If some data is successfully read, soup_socket_read() will return %SOUP_SOCKET_OK, and *@nread will contain the number of bytes actually read (which may be less than @len).

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

class Socket
read
(
ubyte[] buffer
,
out size_t nread
,
Cancellable cancellable
)

Parameters

buffer ubyte[]

buffer to read into

nread size_t

on return, the number of bytes read into @buffer

cancellable Cancellable

a #GCancellable, or %NULL

Return Value

a #SoupSocketIOStatus, as described above (or %SOUP_SOCKET_EOF if the socket is no longer connected, or %SOUP_SOCKET_ERROR on any other error, in which case @error will also be set).

Throws

GException on failure.

Meta