SocketService


Object Hierarchy:

Object hierarchy for SocketService

Description:

[ CCode ( type_id = "g_socket_service_get_type ()" ) ]
[ Version ( since = "2.22" ) ]
public class SocketService : 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 [signal@Gio.SocketService:GSocketService:incoming] signal is emitted.

A `GSocketService` is a subclass of [class@Gio.SocketListener] and you need to add the addresses you want to accept connections on with the [class@Gio.SocketListener] APIs.

There are two options for implementing a network service based on `GSocketService`. The first is to create the service using [ ctor@Gio.SocketService.new] and to connect to the [signal@Gio.SocketService: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 [class@Gio.ThreadedSocketService].

The socket service runs on the main loop of the thread-default context (see [method@GLib.MainContext.push_thread_default]) 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.

All known sub-classes:

Namespace: GLib
Package: gio-2.0

Content:

Properties:

Creation methods:

Methods:

Signals:

Inherited Members: