Gio.Socket.prototype.send_with_blocking

function send_with_blocking(buffer: ByteArray, blocking: Boolean, cancellable: Gio.Cancellable): Number(gssize) {
    // Gjs wrapper for g_socket_send_with_blocking()
}
  

This behaves exactly the same as Gio.Socket.prototype.send, except that the choice of blocking or non-blocking behavior is determined by the blocking argument rather than by socket's properties.

Since 2.26

buffer

the buffer containing the data to send.

blocking

whether to do blocking or non-blocking I/O

cancellable

a %GCancellable or null

Returns

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