Package org.gnome.gio

Class SocketService

java.lang.Object
All Implemented Interfaces:
Proxy
Direct Known Subclasses:
ThreadedSocketService

@Generated("io.github.jwharm.JavaGI") public class SocketService extends SocketListener
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 Gio.SocketService::incoming signal is emitted.

A GSocketService is a subclass of SocketListener and you need to add the addresses you want to accept connections on with the SocketListener APIs.

There are two options for implementing a network service based on GSocketService. The first is to create the service using SocketService() and to connect to the Gio.SocketService::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 ThreadedSocketService.

The socket service runs on the main loop of the thread-default context (see MainContext.pushThreadDefault()) 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.