send_messages


Description:

public int send_messages (OutputMessage[] messages, int flags, int64 timeout, Cancellable? cancellable = null) throws Error

Send one or more data messages from this in one go.

messages must point to an array of OutputMessage structs and messages.length must be the length of this array. Each OutputMessage contains an address to send the data to, and a pointer to an array of OutputVector structs to describe the buffers that the data to be sent for each message will be gathered from.

flags modify how the message is sent. 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.

The other members of OutputMessage are treated as described in its documentation.

If timeout is negative the call will block until messages.length have been sent, cancellable is cancelled, or an error occurs.

If timeout is 0 the call will send up to messages.length without blocking, or will return g_io_error_would_block if there is no space to send messages.

If timeout is positive the call will block on the same conditions as if timeout were negative. If the timeout is reached before any messages are sent, g_io_error_timed_out is returned, otherwise it will return the number of messages sent before timing out.

To be notified when messages can be sent, wait for the g_io_out condition. Note though that you may still receive g_io_error_would_block from send_messages even if you were previously notified of a g_io_out condition. (On Windows in particular, this is very common due to the way the underlying APIs work.)

If the connection is shut down or closed (by calling close or shutdown with shutdown_write set, if it’s a Socket, for example), all calls to this function will return g_io_error_closed.

On error -1 is returned and throws is set accordingly. An error will only be returned if zero messages could be sent; otherwise the number of messages successfully sent before the error will be returned. If cancellable is cancelled, g_io_error_cancelled is returned as with any other error.

Parameters:

this

a DatagramBased

messages

an array of OutputMessage structs

flags

an int containing SocketMsgFlags flags

timeout

the maximum time (in microseconds) to wait, 0 to not block, or -1 to block indefinitely

cancellable

a gcancellable

num_messages

the number of elements in messages

Returns:

number of messages sent, or -1 on error. Note that the number of messages sent may be smaller than messages.length if timeout is zero or positive, or if messages.length was larger than `UIO_MAXIOV` (1024), in which case the caller may re-try to send the remaining messages.