Gio.Socket.prototype.receive_with_blocking

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

This behaves exactly the same as Gio.Socket.prototype.receive, 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

a buffer to read data into (which should be at least size bytes long).

blocking

whether to do blocking or non-blocking I/O

cancellable

a %GCancellable or null

Returns

Number of bytes read, or 0 if the connection was closed by the peer, or -1 on error