public ssize_t send_message (SocketAddress? address, OutputVector[] vectors, SocketControlMessage[]? messages, int flags, Cancellable? cancellable = null) throws Error

Send data to address on this.

For sending multiple messages see send_messages; for easier use, see send and send_to.

If address is null then the message is sent to the default receiver (set by connect).

vectors must point to an array of OutputVector structs and vectors.length must be the length of this array. (If vectors.length is -1, then vectors is assumed to be terminated by a OutputVector with a null buffer pointer.) The OutputVector structs describe the buffers that the sent data will be gathered from. Using multiple OutputVectors is more memory-efficient than manually copying data from multiple sources into a single buffer, and more network-efficient than making multiple calls to send.

messages, if non-null, is taken to point to an array of messages.length SocketControlMessage instances. These correspond to the control messages to be sent on the socket. If messages.length is -1 then messages is treated as a null-terminated array.

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.

If the socket is in blocking mode the call will block until there is space for the data in the socket queue. If there is no space available and the socket is in non-blocking mode a g_io_error_would_block error will be returned. To be notified when space is available, wait for the g_io_out condition. Note though that you may still receive g_io_error_would_block from send 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.)

The sum of the sizes of each OutputVector in vectors must not be greater than g_maxssize. If the message can be larger than this, then it is mandatory to use the send_message_with_timeout function.

On error -1 is returned and throws is set accordingly.



a Socket


a SocketAddress, or null


an array of OutputVector structs


a pointer to an array of SocketControlMessages, or null.


an int containing SocketMsgFlags flags, which may additionally contain other platform specific flags


a gcancellable or null


number of elements in messages, or -1.


the number of elements in vectors, or -1


Number of bytes written (which may be less than size), or -1 on error