GNetworkTcpServer

GNetworkTcpServer — TCP/IP server object.

Synopsis




struct      GNetworkTcpServer;
struct      GNetworkTcpServerClass;
GNetworkTcpServer* gnetwork_tcp_server_new  (const gchar *interface,
                                             guint port);
struct      GNetworkTcpServerCreationData;
G_CONST_RETURN gchar* gnetwork_tcp_server_creation_data_get_address
                                            (const GNetworkTcpServerCreationData *data);
gconstpointer gnetwork_tcp_server_creation_data_get_socket
                                            (const GNetworkTcpServerCreationData *data);
guint16     gnetwork_tcp_server_creation_data_get_port
                                            (const GNetworkTcpServerCreationData *data);
GNetworkTcpServerCreationData* gnetwork_tcp_server_creation_data_dup
                                            (const GNetworkTcpServerCreationData *src);
void        gnetwork_tcp_server_creation_data_free
                                            (GNetworkTcpServerCreationData *data);


Object Hierarchy


  GObject
   +----GNetworkTcpServer

Implemented Interfaces

GNetworkTcpServer implements GNetworkServer.

Properties


  "interface"            gchararray            : Read / Write / Construct
  "interface-info"       GNetworkInterfaceInfo  : Read / Write
  "port"                 guint                 : Read / Write / Construct
  "reverse-lookups"      gboolean              : Read / Write / Construct

Description

The GNetworkTcpServer object and associated functions provides a flexible method for handling incoming TCP/IP connections to a specified port.

Details

struct GNetworkTcpServer

struct GNetworkTcpServer;

This structure contains no public data.


struct GNetworkTcpServerClass

struct GNetworkTcpServerClass {

};

The class structure for a GNetworkTcpServer object.


gnetwork_tcp_server_new ()

GNetworkTcpServer* gnetwork_tcp_server_new  (const gchar *interface,
                                             guint port);

Creates a new, unopened server object for incoming connections on port on interface. The IP address in interface should correspond to the interface that the new server should listen on. If interface is "127.0.0.1", then only connections which come in via the loopback (lo) interface are allowed, whereas if the IP address of eth0 is "192.168.0.10", and interface is set to "192.168.0.10", then only connections which come in over eth0 are accepted, etc. This functions as a bare-bones firewall for this server, though if more complicated firewalls are required (at this level), a custom connection-creation function could do the trick.

interface : the local IP interface to use, or NULL.
port : the local port to allow connections through.
Returns : a new GNetworkTcpServer object.

Since 1.0


struct GNetworkTcpServerCreationData

struct GNetworkTcpServerCreationData;

The data GNetworkTcpServer passes via a GValue's boxed field to the user-set "create func".


gnetwork_tcp_server_creation_data_get_address ()

G_CONST_RETURN gchar* gnetwork_tcp_server_creation_data_get_address
                                            (const GNetworkTcpServerCreationData *data);

Retrieves the string of the host IP address of the incoming connection in data.

data : the connection creation data to examine.
Returns : the address of data.

gnetwork_tcp_server_creation_data_get_socket ()

gconstpointer gnetwork_tcp_server_creation_data_get_socket
                                            (const GNetworkTcpServerCreationData *data);

Retrieves the socket data (a file descriptor on Unix) in data.

data : the connection creation data to examine.
Returns : the address of data.

gnetwork_tcp_server_creation_data_get_port ()

guint16     gnetwork_tcp_server_creation_data_get_port
                                            (const GNetworkTcpServerCreationData *data);

Retrieves the port in data. This value is

data : the connection creation data to examine.
Returns : the address of data.

gnetwork_tcp_server_creation_data_dup ()

GNetworkTcpServerCreationData* gnetwork_tcp_server_creation_data_dup
                                            (const GNetworkTcpServerCreationData *src);

Creates a copy of the creation data in src. The returned data should be freed with gnetwork_tcp_server_creation_data_free() when no longer needed.

src : the creation data to copy.
Returns : a newly allocated copy of src.

Since 1.0


gnetwork_tcp_server_creation_data_free ()

void        gnetwork_tcp_server_creation_data_free
                                            (GNetworkTcpServerCreationData *data);

Frees the memory used by data.

data : the creation data to delete.

Since 1.0

Properties

The "interface" property

  "interface"            gchararray            : Read / Write / Construct

The name of the interface to allow connections to (e.g. "eth0").

Default value: NULL


The "interface-info" property

  "interface-info"       GNetworkInterfaceInfo  : Read / Write

The hostname or IP address of the interface to allow connections to.


The "port" property

  "port"                 guint                 : Read / Write / Construct

The port number to allow connections to.

Allowed values: <= 65535

Default value: 0


The "reverse-lookups" property

  "reverse-lookups"      gboolean              : Read / Write / Construct

Whether or not to perform reverse lookups on incoming connections.

Default value: FALSE