Socket.getOption

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; g_socket_get_option() will handle the conversion internally.

class Socket
bool
getOption
(
int level
,,
out int value
)

Parameters

level int

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

optname int

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

value int

return location for the option value

Return Value

Type: bool

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.

Throws

GException on failure.

Meta

Since

2.36