Description Methods and Functions Hierarchy Detailed Description Structures Convenient Construction Signals Author(s) References
Make it easy to implement a network service
gSocketServiceNew()
gSocketServiceStart(object)
gSocketServiceStop(object)
gSocketServiceIsActive(object)
gSocketService()
1 2 3 4 | GObject
+----GSocketListener
+----GSocketService
+----GThreadedSocketService
|
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.
GSocketService
A helper class for handling accepting incomming connections in the glib mainloop. Since 2.22
gSocketService
is the equivalent of gSocketServiceNew
.
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
Derived by RGtkGen from GTK+ documentation
https://developer.gnome.org/gio/stable/GSocketService.html
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.