GSocketService: GSocketService

Description Methods and Functions Hierarchy Detailed Description Structures Convenient Construction Signals Author(s) References

Description

Make it easy to implement a network service

Methods and Functions

gSocketServiceNew()
gSocketServiceStart(object)
gSocketServiceStop(object)
gSocketServiceIsActive(object)
gSocketService()

Hierarchy

1
2
3
4

Detailed Description

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 "incoming" signal is emitted.

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

There are two options for implementing a network service based on GSocketService. The first is to create the service using gSocketServiceNew and to connect to the "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 in the main thread, and is not threadsafe in general. However, the calls to start and stop the service are threadsafe so these can be used from threads that handle incoming clients.

Structures

GSocketService

A helper class for handling accepting incomming connections in the glib mainloop. Since 2.22

Convenient Construction

gSocketService is the equivalent of gSocketServiceNew.

Signals

incoming(service, connection, source.object, user.data)

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. Since 2.22

service

the GSocketService.

connection

a new GSocketConnection object.

source.object

the source_object passed to gSocketListenerAddAddress.

user.data

user data set when the signal handler was connected.

Returns: [logical] TRUE to stop other handlers from being called

Author(s)

Derived by RGtkGen from GTK+ documentation

References

https://developer.gnome.org/gio/stable/GSocketService.html


RGtk2 documentation built on Oct. 14, 2021, 5:08 p.m.

Related to GSocketService in RGtk2...