Gio.Socket.prototype.get_option

function get_option(level: Number(gint), optname: Number(gint)): [ok: Boolean, value: Number(gint)] {
    // Gjs wrapper for g_socket_get_option()
}
  

Gets the value of an integer-valued option on socket, as with getsockopt(). (If you need to fetch a non-integer-valued option, you will need to call getsockopt() directly.)

The [<gio/gnetworking.h>][gio-gnetworking.h] header pulls in system headers that will define most of the standard/portable socket options. For unusual socket protocols or platform-dependent options, you may need to include additional headers.

Note that even for socket options that are a single byte in size, value is still a pointer to a #gint variable, not a #guchar; Gio.Socket.prototype.get_option will handle the conversion internally.

Since 2.36

level

the "API level" of the option (eg, `SOL_SOCKET`)

optname

the "name" of the option (eg, `SO_BROADCAST`)

ok

success or failure. On failure, @error will be set, and the system error value (`errno` or WSAGetLastError()) will still be set to the result of the getsockopt() call.

value

return location for the option value