## SOCKS

SOCKS — SOCKS proxy

## Synopsis

    #define     GNET_SOCKS_PORT
    #define     GNET_SOCKS_VERSION
    gboolean    gnet_socks_get_enabled          (void);
    void        gnet_socks_set_enabled          (gboolean enabled);
    GInetAddr*  gnet_socks_get_server           (void);
    void        gnet_socks_set_server           (const GInetAddr *inetaddr);
    gint        gnet_socks_get_version          (void);
    void        gnet_socks_set_version          (gint version);

## Description

SOCKS is a TCP proxy protocol. Typically, a host behind a firewall uses SOCKS to connect to hosts outside the firewall via a SOCKS proxy server. To open a TCP connection, a SOCKS client connects to a SOCKS server and the SOCKS server connects to the destination. Data is then forwarded between the client and the destination by the SOCKS server. GNet supports SOCKS versions 4 and 5. Version 5 includes support for server sockets.

SOCKS is used if the SOCKS_SERVER environment variable is set or `gnet_socks_set_server()` is called to set the SOCKS server's address. To disable SOCKS support, call `gnet_socks_set_enabled()` and pass FALSE. The SOCKS_VERSION environment variable controls which SOCKS version is used. The default is version 5.

## Details

### GNET_SOCKS_PORT

    #define GNET_SOCKS_PORT 1080

Default port for the SOCKS protocol.

### GNET_SOCKS_VERSION

    #define GNET_SOCKS_VERSION 5

Default version of the SOCKS protocol.

### gnet_socks_get_enabled ()

    gboolean    gnet_socks_get_enabled          (void);

Determines whether SOCKS support is enabled.

Returns : | TRUE if SOCKS is enabled, FALSE otherwise.

### gnet_socks_set_enabled ()

    void        gnet_socks_set_enabled          (gboolean enabled);

Sets whether SOCKS support is enabled.

`enabled` : | is SOCKS support enabled?

### gnet_socks_get_server ()

    GInetAddr*  gnet_socks_get_server           (void);

Gets the address of the SOCKS server (regardless of whether SOCKS is enabled). This function checks the `gnet_socks_set_server()` value and, if not set, the SOCKS_SERVER environment variable. The SOCKS_SERVER enviroment variable should be in the form HOSTNAME or HOSTNAME:PORT.

Returns : | a copy of the address; NULL if there is no server.

### gnet_socks_set_server ()

    void        gnet_socks_set_server           (const GInetAddr *inetaddr);

Sets the address of the SOCKS server.

`inetaddr` : | SOCKS server address

### gnet_socks_get_version ()

    gint        gnet_socks_get_version          (void);

Gets the SOCKS version GNet uses. This function checks the `gnet_socks_set_version()` value and, if not set, the SOCKS_VERSION environment variable.

Returns : | the SOCKS version.

### gnet_socks_set_version ()

    void        gnet_socks_set_version          (gint version);

Sets the SOCKS version GNet uses. GNet only supports versions 4 and 5.

`version` : | SOCKS version