Gio.Socket.prototype.send

function send(buffer: ByteArray, cancellable: Gio.Cancellable): Number(gssize) {
    // Gjs wrapper for g_socket_send()
}
  

Tries to send size bytes from buffer on the socket. This is mainly used by connection-oriented sockets; it is identical to Gio.Socket.prototype.send_to with @address set to null.

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 Gio.IOErrorEnum.would_block error will be returned. To be notified when space is available, wait for the GLib.IOCondition.out condition. Note though that you may still receive Gio.IOErrorEnum.would_block from Gio.Socket.prototype.send even if you were previously notified of a GLib.IOCondition.out condition. (On Windows in particular, this is very common due to the way the underlying APIs work.)

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

Since 2.22

buffer

the buffer containing the data to send.

cancellable

a %GCancellable or null

Returns

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