Gio.Socket.get_option

### Method

# Gio Socketget_option

since: 2.36

#### Declaration

    gboolean
    g_socket_get_option (
      GSocket* socket,
      gint level,
      gint optname,
      gint* value,
      GError** error
    )

#### Description

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] 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.

Available since: 2.36

#### Parameters

`level`

  Type: `gint`

  The “API level” of the option (eg, `SOL_SOCKET`)

`optname`

  Type: `gint`

  The “name” of the option (eg, `SO_BROADCAST`)

`value`

  Type: `gint*`

  Return location for the option value.

  The argument will be set by the function.

`error`

  Type: `GError **`

  The return location for a recoverable error.

  The argument can be `NULL`.
  If the return location is not `NULL`, then you must initialize it to a `NULL` `GError*`.
  The argument will be left initialized to `NULL` by the method if there are no errors.
  In case of error, the argument will be set to a newly allocated `GError`; the caller will take ownership of the data, and be responsible for freeing it.

#### Return value

Type: `gboolean`

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.