Gio.SocketService
const Gio = imports.gi.Gio; let socketService = new Gio.SocketService();
A Gio.SocketService 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 Gio.SocketService::incoming signal is emitted.
A Gio.SocketService is a subclass of Gio.SocketListener and you need to add the addresses you want to accept connections on with the Gio.SocketListener APIs.
There are two options for implementing a network service based on Gio.SocketService. The first is to create the service using Gio.SocketService.new and to connect to the Gio.SocketService::incoming signal. The second is to subclass Gio.SocketService 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 Gio.ThreadedSocketService.
The socket service runs on the main loop of the [thread-default context][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.
Since 2.22
Hierarchy
-
GObject.Object
-
Gio.SocketListener
- Gio.SocketService
-