![]() |
![]() |
![]() |
GNetwork Library Manual | ![]() |
---|---|---|---|---|
GNetworkTcpServer; GNetworkTcpServerClass; GNetworkTcpServer* gnetwork_tcp_server_new (const gchar *interface, guint port); GNetworkTcpServerCreationData; const 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);
"interface" gchararray : Read / Write / Construct "interface-info" GNetworkInterfaceInfo : Read / Write "port" guint : Read / Write / Construct "reverse-lookups" gboolean : Read / Write / Construct
The GNetworkTcpServer object and associated functions provides a flexible method for handling incoming TCP/IP connections to a specified port.
typedef struct _GNetworkTcpServer GNetworkTcpServer;
This structure contains no public data.
typedef struct { } GNetworkTcpServerClass;
The class structure for a GNetworkTcpServer object.
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
typedef struct _GNetworkTcpServerCreationData GNetworkTcpServerCreationData;
The data GNetworkTcpServer passes via a GValue's boxed field to the user-set "create func".
const 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 .
|
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 .
|
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 .
|
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
void gnetwork_tcp_server_creation_data_free (GNetworkTcpServerCreationData *data);
Frees the memory used by data
.
data : |
the creation data to delete. |
Since 1.0
interface
" property"interface" gchararray : Read / Write / Construct
The name of the interface to allow connections to (e.g. "eth0").
Default value: NULL
interface-info
" property"interface-info" GNetworkInterfaceInfo : Read / Write
The hostname or IP address of the interface to allow connections to.
port
" property"port" guint : Read / Write / Construct
The port number to allow connections to.
Allowed values: <= 65535
Default value: 0
reverse-lookups
" property"reverse-lookups" gboolean : Read / Write / Construct
Whether or not to perform reverse lookups on incoming connections.
Default value: FALSE