receive_bytes


Description:

[ Version ( since = "2.80" ) ]
public Bytes receive_bytes (size_t size, int64 timeout_us, Cancellable? cancellable = null) throws Error

Receives data (up to size bytes) from a socket.

This function is a variant of [method@Gio.Socket.receive] which returns a [struct@GLib.Bytes] rather than a plain buffer.

Pass `-1` to timeout_us to block indefinitely until data is received (or the connection is closed, or there is an error). Pass `0` to use the default timeout from [property@Gio.Socket:timeout], or pass a positive number to wait for that many microseconds for data before returning `G_IO_ERROR_TIMED_OUT`.

Parameters:

this

a Socket

size

the number of bytes you want to read from the socket

timeout_us

the timeout to wait for, in microseconds, or `-1` to block indefinitely

cancellable

a gcancellable, or `NULL`

Returns:

a bytes buffer containing the received bytes, or `NULL` on error