SocketService
A #GSocketService is an object that represents a service that is provided to the network or over local sockets. When a new connection is made to the service the #GSocketService::incoming signal is emitted.
A #GSocketService is a subclass of #GSocketListener and you need to add the addresses you want to accept connections on with the #GSocketListener APIs.
There are two options for implementing a network service based on #GSocketService. The first is to create the service using g_socket_service_new() and to connect to the #GSocketService::incoming signal. The second is to subclass #GSocketService and override the default signal handler implementation.
In either case, the handler must immediately return, or else it will block additional incoming connections from being serviced. If you are interested in writing connection handlers that contain blocking code then see #GThreadedSocketService.
The socket service runs on the main loop of the g-main-context-push-thread-default-context of the thread it is created in, and is not threadsafe in general. However, the calls to start and stop the service are thread-safe so these can be used from threads that handle incoming clients.
Skipped during bindings generation
method
active
: Property has no getter nor setter
Since
2.22
Inheritors
Constructors
Functions
This is the asynchronous version of g_socket_listener_accept().
This is the asynchronous version of g_socket_listener_accept_socket().
Listens for TCP connections on any available port number for both IPv6 and IPv4 (if each is available).
Helper function for g_socket_listener_add_address() that creates a TCP/IP socket listening on IPv4 and IPv6 (if supported) on the specified port on all interfaces.
Emitted when @listener's activity on @socket changes state. Note that when @listener is used to listen on both IPv4 and IPv6, a separate set of signals will be emitted for each, and the order they happen in is undefined.
The ::incoming signal is emitted when a new incoming connection to @service needs to be handled. The handler must initiate the handling of @connection, but may not block; in essence, asynchronous operations must be used.
Sets the listen backlog on the sockets in the listener. This must be called before adding any sockets, addresses or ports to the #GSocketListener (for example, by calling g_socket_listener_add_inet_port()) to be effective.