Gio.Socket.prototype.set_timeout
function set_timeout(timeout: Number(guint)): void { // Gjs wrapper for g_socket_set_timeout() }
Sets the time in seconds after which I/O operations on socket will time out if they have not yet completed.
On a blocking socket, this means that any blocking Gio.Socket operation will time out after timeout seconds of inactivity, returning Gio.IOErrorEnum.timed_out.
On a non-blocking socket, calls to Gio.Socket.prototype.condition_wait will also fail with Gio.IOErrorEnum.timed_out after the given time. Sources created with Gio.Socket.create_source will trigger after timeout seconds of inactivity, with the requested condition set, at which point calling Gio.Socket.prototype.receive, Gio.Socket.prototype.send, Gio.Socket.prototype.check_connect_result, etc, will fail with Gio.IOErrorEnum.timed_out.
If timeout is 0 (the default), operations will never time out on their own.
Note that if an I/O operation is interrupted by a signal, this may cause the timeout to be reset.
Since 2.26
- timeout
the timeout for socket, in seconds, or 0 for none