![]() | ![]() | ![]() | GTcpSocket Library Manual | ![]() |
---|
GTcpServer — The incoming connection handling object.
struct GTcpServer; enum GTcpServerKillStyle; enum GTcpServerOpenStatus; GObject* gtcp_server_new (guint local_port, gboolean use_ssl, const gchar *local_address); GTcpServerOpenStatus gtcp_server_open (GTcpServer *server); void gtcp_server_close (GTcpServer *server); gboolean gtcp_server_is_open (GTcpServer *server); G_CONST_RETURN gchar* gtcp_server_get_local_address (GTcpServer *server); void gtcp_server_set_local_address (GTcpServer *server, const gchar *local_address); guint gtcp_server_get_local_port (GTcpServer *server); void gtcp_server_set_local_port (GTcpServer *server, guint local_port); gboolean gtcp_server_get_use_ssl (GTcpServer *server); gboolean gtcp_server_set_use_ssl (GTcpServer *server, gboolean use_ssl); gint gtcp_server_get_max_connections (GTcpServer *server); void gtcp_server_set_max_connections (GTcpServer *server, gint max_connections); GTcpServerKillStyle gtcp_server_get_kill_style (GTcpServer *server); void gtcp_server_set_kill_style (GTcpServer *server, GTcpServerKillStyle kill_style); gboolean gtcp_server_get_do_reverse_lookups (GTcpServer *server); void gtcp_server_set_do_reverse_lookups (GTcpServer *server, gboolean do_reverse_lookups); void gtcp_server_set_buffer_size (GTcpServer *server, gsize buffer_size); gsize gtcp_server_get_buffer_size (GTcpServer *server); gulong gtcp_server_get_bytes_read (GTcpServer *server); gulong gtcp_server_get_bytes_written (GTcpServer *server);
GObject +----GTcpServer
"buffer-size" guint : Read / Write / Construct "bytes-read" gulong : Read "bytes-written" gulong : Read "connections" gpointer : Read "do-reverse-lookups" gboolean : Read / Write / Construct "kill-style" GTcpServerKillStyle : Read / Write / Construct "local-address" gchararray : Read / Write / Construct "max-connections" gint : Read / Write / Construct "port" guint : Read / Write / Construct "use-ssl" gboolean : Read / Write / Construct
"closed" void user_function (GTcpServer *gtcpserver, gpointer user_data); "incoming" void user_function (GTcpServer *gtcpserver, GTcpConnection *arg1, gpointer user_data);
The GTcpServer object and associated functions provides a flexible method for handling incoming connections to a specified port.
struct GTcpServer;
The GTcpServer struct contains only read-only fields. They should never be set by an application.
typedef enum /*< prefix=GTCP_SERVER > */ { GTCP_SERVER_LEAVE_OPEN, GTCP_SERVER_KILL_ON_CLOSE, GTCP_SERVER_KILL_ON_FINALIZE, GTCP_SERVER_FINALIZE_ON_CLOSE, GTCP_SERVER_FINALIZE_ON_FINALIZE } GTcpServerKillStyle;
The kill policy to use for GTcpConnection objects that are opened by the server.
GTCP_SERVER_LEAVE_OPEN | Leave the GTcpConnection objects opened by this server open. |
GTCP_SERVER_KILL_ON_CLOSE | Close the GTcpConnection objects when the server is closed. |
GTCP_SERVER_KILL_ON_FINALIZE | Close the GTcpConnection objects when the server is finalized (with g_object_unref()). |
GTCP_SERVER_FINALIZE_ON_CLOSE | Unref the GTcpConnection objects when the server is closed. |
GTCP_SERVER_FINALIZE_ON_FINALIZE | Unref the GTcpConnection objects when the server is finalized (with g_object_unref()). |
typedef enum /* < prefix=GTCP_SERVER_OPEN > */ { GTCP_SERVER_OPEN_OK, GTCP_SERVER_OPEN_OPENING, GTCP_SERVER_OPEN_ERROR_NO_LOCAL_HOSTNAME, GTCP_SERVER_OPEN_ERROR_SOCKET_TYPE_PERMS, GTCP_SERVER_OPEN_ERROR_NO_MEM, GTCP_SERVER_OPEN_ERROR_TABLE_OVERFLOW, GTCP_SERVER_OPEN_ERROR_LOW_PORT_PERMS, GTCP_SERVER_OPEN_ERROR_ALREADY_BOUND, GTCP_SERVER_OPEN_ERROR_INTERNAL_ERROR } GTcpServerOpenStatus;
Used by gtcp_server_open() to provide a descriptive error on the status. User applications should use gtcp_error_get_server_open_status_message() to get a properly formatted error string for use in an error message box.
GTCP_SERVER_OPEN_OK | The GTcpServer is open and ready. |
GTCP_SERVER_OPEN_OPENING | The GTcpServer is in the process of opening (gtcp_server_open() has not returned yet). |
GTCP_SERVER_OPEN_ERROR_NO_LOCAL_HOSTNAME | The address passed is not a local address, or there are no open network interfaces. |
GTCP_SERVER_OPEN_ERROR_SOCKET_TYPE_PERMS | The user does not have permission to open TCP/IP sockets (this is a system configuration error). |
GTCP_SERVER_OPEN_ERROR_NO_MEM | There is not enough available memory to open a new socket. |
GTCP_SERVER_OPEN_ERROR_TABLE_OVERFLOW | There are too many open sockets already. |
GTCP_SERVER_OPEN_ERROR_LOW_PORT_PERMS | The port is under 1024, and requires special permissions to use these ports. |
GTCP_SERVER_OPEN_ERROR_ALREADY_BOUND | There is already an open server (probably a service) on the requested port. |
GTCP_SERVER_OPEN_ERROR_INTERNAL_ERROR | An unrecoverable internal error occurred inside the LibGTcpSocket library (usually indicative of a larger system problem). |
GObject* gtcp_server_new (guint local_port, gboolean use_ssl, const gchar *local_address);
Creates a new, unopened GTcpServer.
local_port : | the local port to allow connections through. |
use_ssl : | whether to use SSL or not. |
local_address : | the local address to use (optional). |
Returns : | a new GTcpServer. |
Since 1.0
GTcpServerOpenStatus gtcp_server_open (GTcpServer *server);
Causes the GTcpServer to start accepting incoming connections.
server : | the GTcpServer to start accepting connections to. |
Returns : | a GTcpServerOpenStatus for success or error |
Since 1.0
void gtcp_server_close (GTcpServer *server);
Causes a GTcpServer to stop accepting incoming connections. If the GTcpServer kill-style property is set to kill on close, any GTcpConnections opened by this server will be closed.
server : | the GTcpServer to stop accepting connections to. |
Since 1.0
gboolean gtcp_server_is_open (GTcpServer *server);
Checks if a GTcpServer is ready to accept incoming connections.
server : | the GTcpServer to check. |
Returns : | TRUE if it is ready, FALSE if it is not. |
Since 1.0
G_CONST_RETURN gchar* gtcp_server_get_local_address (GTcpServer *server);
Gets the local address a GTcpServer is set to force, or NULL if none is set. The returned string should not be freed or modified.
server : | the GTcpServer to get the address to. |
Returns : | the local address, or NULL. |
Since 1.0
void gtcp_server_set_local_address (GTcpServer *server, const gchar *local_address);
Sets the local IP address a GTcpServer will attempt to force. If address is NULL, the server will use the default local address (Recommended).
server : | the GTcpServer to set the local address for. |
local_address : | the new local IP address, or NULL, to use any address. |
Since 1.0
guint gtcp_server_get_local_port (GTcpServer *server);
Gets the local port a GTcpServer is set to allow connections to.
server : | the GTcpServer to get the port being used. |
Returns : | a guint corresponding to the outgoing port. |
Since 1.0
void gtcp_server_set_local_port (GTcpServer *server, guint local_port);
Sets the local port a GTcpServer will allow connections to.
server : | the GTcpServer to set the outgoing port for. |
local_port : | the new local port. |
Since 1.0
gboolean gtcp_server_get_use_ssl (GTcpServer *server);
Gets whether SSL will be used for connections to this GTcpServer.
server : | the GTcpServer to get whether SSL being used. |
Returns : | a gboolean corresponding to whether SSL will be used or not. |
Since 1.0
gboolean gtcp_server_set_use_ssl (GTcpServer *server, gboolean use_ssl);
Sets whether a GTcpServer will use SSL for new incoming connections.
server : | the GTcpServer to set the outgoing port for. |
use_ssl : | whether to use SSL for incoming connections or not. |
Returns : | a gboolean corresponding to whether SSL support was included or not. |
Since 1.0
gint gtcp_server_get_max_connections (GTcpServer *server);
Gets the maximum number of incoming connections a GTcpServer will allow.
server : | the GTcpServer to get the maximum allowed connections. |
Returns : | a gint corresponding to the maximum number of incoming connections. |
Since 1.0
void gtcp_server_set_max_connections (GTcpServer *server, gint max_connections);
Sets the maximum number of incoming connections a GTcpServer will allow. Setting to zero will disallow any new connections, and -1 will allow an unlimited number of connections (Not recommended). Changing this property for an open connection will not close any connections which are already open, it will only affect whether or not to allow new connections.
server : | the GTcpServer to set the maxumum allowed connections for. |
max_connections : | the new maximum |
Since 1.0
GTcpServerKillStyle gtcp_server_get_kill_style (GTcpServer *server);
Gets the kill policy a GTcpServer will follow for killing it's connections.
server : | the GTcpServer to get the kill policy for. |
Returns : | a GTcpServerKillStyle enum corresponding to the kill policy. |
Since 1.0
void gtcp_server_set_kill_style (GTcpServer *server, GTcpServerKillStyle kill_style);
Sets the kill policy for a GTcpServer. See GTcpServerKillStyle for more information.
server : | the GTcpServer to set the kill policy for. |
kill_style : | the GTcpServerKillStyle to use. |
Since 1.0
gboolean gtcp_server_get_do_reverse_lookups (GTcpServer *server);
Gets whether a reverse DNS lookup will be performed on incoming connections to this GTcpServer.
server : | the GTcpServer to get whether to perform reverse DNS lookups or not. |
Returns : | A gboolean corresponding to whether reverse DNS lookups will be performed or not. |
Since 1.0
void gtcp_server_set_do_reverse_lookups (GTcpServer *server, gboolean do_reverse_lookups);
Sets whether a GTcpServer will perform reverse DNS lookups on incoming connections.
server : | the GTcpServer to set the outgoing port for. |
do_reverse_lookups : | whether to perform reverse DNS lookups or not. |
Since 1.0
void gtcp_server_set_buffer_size (GTcpServer *server, gsize buffer_size);
This sets the buffer size used for new GTcpConnection objects. See also: GTCP_SOCKET_DEFAULT_BUFFER_SIZE.
server : | the GTcpServer to change the default buffer size of. |
buffer_size : | the new buffer size. |
Since 1.0
gsize gtcp_server_get_buffer_size (GTcpServer *server);
This retrieves the buffer size used for new GTcpConnection objects. See also: GTCP_SOCKET_DEFAULT_BUFFER_SIZE.
server : | the GTcpServer to retrieve the default buffer size of. |
Returns : | the current default buffer size. |
Since 1.0
gulong gtcp_server_get_bytes_read (GTcpServer *server);
This gets the number of bytes recieved by a GTcpServer for all connections. This counter is reset to zero when the server is opened, so if you close the GTcpServer, then open it, the counter will be reset.
server : | the GTcpServer to get the number of bytes read from. |
Returns : | the number of bytes read so far. |
Since 1.0
gulong gtcp_server_get_bytes_written (GTcpServer *server);
This gets the number of bytes recieved by a GTcpServer for all connections. This counter is reset to zero when the server is opened, so if you close the GTcpServer, then open it, the counter will be reset.
server : | the GTcpServer to get the number of bytes written to. |
Returns : | the number of bytes sent so far. |
Since 1.0
"buffer-size" (guint : Read / Write / Construct) | The default read/write buffer size (limited by the system) for new incoming connections. See also: GTCP_SOCKET_DEFAULT_BUFFER_SIZE. |
"bytes-read" (gulong : Read) | The total number of bytes received by all incoming connections to this service. |
"bytes-written" (gulong : Read) | The total number of bytes sent out over all incoming connections to this service. |
"connections" (gpointer : Read) | A GList of all open connections to this service. |
"do-reverse-lookups" (gboolean : Read / Write / Construct) | Whether or not to perform reverse DNS lookups on incoming connections. The connections will be established irregardless of whether the lookup has returned. |
"kill-style" (GTcpServerKillStyle : Read / Write / Construct) | If/when to kill connections to this service. |
"local-address" (gchararray : Read / Write / Construct) | The local IP address used for the service. |
"max-connections" (gint : Read / Write / Construct) | The maximum number of incoming connections to allow. |
"port" (guint : Read / Write / Construct) | The local port number used for this service. |
"use-ssl" (gboolean : Read / Write / Construct) | Whether or not to encrypt incoming connections with SSL. |
void user_function (GTcpServer *gtcpserver, gpointer user_data);
This signal is emitted when a GTcpServer is no longer accepting connections. Depending on the kill-style property, the associated GTcpConnections may be closed.
gtcpserver : | the object which received the signal. |
user_data : | user data set when the signal handler was connected. |
void user_function (GTcpServer *gtcpserver, GTcpConnection *arg1, gpointer user_data);
This signal is emitted when a new incoming connection has been established.
gtcpserver : | the object which received the signal. |
arg1 : | A GTcpConnection corresponding to the new connection. |
user_data : | user data set when the signal handler was connected. |
<< GTcpConnection | DNS Lookups >> |