Class

GioThreadedSocketService

Description [src]

class Gio.ThreadedSocketService : Gio.SocketService {
  parent_instance: GSocketService,
  priv: GThreadedSocketServicePrivate*
}

A GThreadedSocketService is a simple subclass of GSocketService that handles incoming connections by creating a worker thread and dispatching the connection to it by emitting the GThreadedSocketService::run signal in the new thread.

The signal handler may perform blocking IO and need not return until the connection is closed.

The service is implemented using a thread pool, so there is a limited amount of threads available to serve incoming requests. The service automatically stops the GSocketService from accepting new connections when all threads are busy.

As with GSocketService, you may connect to GThreadedSocketService::run, or subclass and override the default handler.

Available since:2.22

Hierarchy

hierarchy this GThreadedSocketService ancestor_0 GSocketService ancestor_0--this ancestor_1 GSocketListener ancestor_1--ancestor_0 ancestor_2 GObject ancestor_2--ancestor_1

Constructors

g_threaded_socket_service_new

Creates a new GThreadedSocketService with no listeners. Listeners must be added with one of the GSocketListener add” methods.

Available since: 2.22

Instance methods

Methods inherited from GSocketService (3)
g_socket_service_is_active

Check whether the service is active or not. An active service will accept new clients that connect, while a non-active service will let connecting clients queue up until the service is started.

Available since: 2.22

g_socket_service_start

Restarts the service, i.e. start accepting connections from the added sockets when the mainloop runs. This only needs to be called after the service has been stopped from g_socket_service_stop().

Available since: 2.22

g_socket_service_stop

Stops the service, i.e. stops accepting connections from the added sockets when the mainloop runs.

Available since: 2.22

Methods inherited from GSocketListener (12)
g_socket_listener_accept

Blocks waiting for a client to connect to any of the sockets added to the listener. Returns a GSocketConnection for the socket that was accepted.

Available since: 2.22

g_socket_listener_accept_async

This is the asynchronous version of g_socket_listener_accept().

Available since: 2.22

g_socket_listener_accept_finish

Finishes an async accept operation. See g_socket_listener_accept_async()

Available since: 2.22

g_socket_listener_accept_socket

Blocks waiting for a client to connect to any of the sockets added to the listener. Returns the GSocket that was accepted.

Available since: 2.22

g_socket_listener_accept_socket_async

This is the asynchronous version of g_socket_listener_accept_socket().

Available since: 2.22

g_socket_listener_accept_socket_finish

Finishes an async accept operation. See g_socket_listener_accept_socket_async()

Available since: 2.22

g_socket_listener_add_address

Creates a socket of type type and protocol protocol, binds it to address and adds it to the set of sockets we’re accepting sockets from.

Available since: 2.22

g_socket_listener_add_any_inet_port

Listens for TCP connections on any available port number for both IPv6 and IPv4 (if each is available).

Available since: 2.24

g_socket_listener_add_inet_port

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.

Available since: 2.22

g_socket_listener_add_socket

Adds socket to the set of sockets that we try to accept new clients from. The socket must be bound to a local address and listened to.

Available since: 2.22

g_socket_listener_close

Closes all the sockets in the listener.

Available since: 2.22

g_socket_listener_set_backlog

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.

Available since: 2.22

Methods inherited from GObject (43)

Properties

Gio.ThreadedSocketService:max-threads
No description available.
Properties inherited from GSocketService (1)
Gio.SocketService:active

Whether the service is currently accepting connections.

Available since: 2.46

Properties inherited from GSocketListener (1)
Gio.SocketListener:listen-backlog
No description available.

Signals

Gio.ThreadedSocketService::run

The ::run signal is emitted in a worker thread in response to an incoming connection. This thread is dedicated to handling connection and may perform blocking IO. The signal handler need not return until the connection is closed.

Signals inherited from GSocketService (1)
Gio.SocketService::incoming

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.

Available since: 2.22

Signals inherited from GSocketListener (1)
Gio.SocketListener::event

Emitted when listeners 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.

Available since: 2.46

Signals inherited from GObject (1)

Class structure

struct GioThreadedSocketServiceClass {
  GSocketServiceClass parent_class;
  gboolean (* run) (
    GThreadedSocketService* service,
    GSocketConnection* connection,
    GObject* source_object
  );
  void (* _g_reserved1) (
void
  );
  void (* _g_reserved2) (
void
  );
  void (* _g_reserved3) (
void
  );
  void (* _g_reserved4) (
void
  );
  void (* _g_reserved5) (
void
  );
  
}
Class members
parent_class
GSocketServiceClass
  No description available.
run
gboolean (* run) (
    GThreadedSocketService* service,
    GSocketConnection* connection,
    GObject* source_object
  )
  No description available.
_g_reserved1
void (* _g_reserved1) (
void
  )
  No description available.
_g_reserved2
void (* _g_reserved2) (
void
  )
  No description available.
_g_reserved3
void (* _g_reserved3) (
void
  )
  No description available.
_g_reserved4
void (* _g_reserved4) (
void
  )
  No description available.
_g_reserved5
void (* _g_reserved5) (
void
  )
  No description available.

Virtual methods

Gio.ThreadedSocketServiceClass.run
No description available.