public int receive_messages (InputMessage messages, int flags, Cancellable? cancellable = null) throws Error
Receive multiple data messages from this in one go.
messages must point to an array of InputMessage structs and
messages.length must be the length of this array. Each InputMessage
contains a pointer to an array of InputVector structs describing the buffers that
the data received in each message will be written to. Using multiple InputVectors is
more memory-efficient than manually copying data out of a single buffer to multiple sources, and more system-call-efficient than making
multiple calls to receive, such as in scenarios where a lot of data packets need
to be received (e.g. high-bandwidth video streaming over RTP/UDP).
flags modify how all messages are received. The commonly available arguments for this are available in the
SocketMsgFlags enum, but the values there are the same as the system values, and
the flags are passed in as-is, so you can pass in system-specific flags too. These flags affect the overall receive operation. Flags affecting
individual messages are returned in flags.
The other members of InputMessage are treated as described in its documentation.
If blocking is true the call will block
messages.length have been received, or the end of the stream is reached.
If blocking is false the call will return
messages.length without blocking, or g_io_error_would_block if no messages are queued in
the operating system to be received.
In blocking mode, if timeout is positive and is reached before any messages
are received, g_io_error_timed_out is returned, otherwise up to
messages.length are returned. (
Note: This is effectively the behaviour of `MSG_WAITFORONE` with
To be notified when messages are available, wait for the g_io_in condition. Note though that you may still receive g_io_error_would_block from receive_messages even if you were previously notified of a g_io_in condition.
If the remote peer closes the connection, any messages queued in the operating system will be returned, and subsequent calls to receive_messages will return 0 (with no error set).
On error -1 is returned and throws is set accordingly. An error will only be returned if zero messages could be received; otherwise the number of messages successfully received before the error will be returned.
an array of InputMessage structs
a gcancellable or null
the number of elements in
number of messages received, or -1 on error. Note that the number of messages received may be smaller than