SocketListener
Object Hierarchy:
Description:
[
CCode ( type_id =
"g_socket_listener_get_type ()" ) ]
[
Version ( since =
"2.22" ) ]
public class SocketListener :
Object
A `GSocketListener` is an object that keeps track of a set of server sockets and helps you accept sockets from any of the socket, either
sync or async.
Add addresses and ports to listen on using [method@Gio.SocketListener.add_address] and [method@Gio.SocketListener.add_inet_port]. These
will be listened on until [method@Gio.SocketListener.close] is called. Dropping your final reference to the `GSocketListener` will not
cause [method@Gio.SocketListener.close] to be called implicitly, as some references to the `GSocketListener` may be held internally.
If you want to implement a network server, also look at [class@Gio.SocketService] and [class@Gio.ThreadedSocketService] which are
subclasses of `GSocketListener` that make this even easier.
Content:
Properties:
Creation methods:
Methods:
- public SocketConnection accept (out unowned Object? source_object = null, Cancellable? cancellable = null) throws Error
Blocks waiting for a client to connect to any of the sockets added to
the listener.
- public async SocketConnection accept_async (Cancellable? cancellable = null, out unowned Object? source_object = null) throws Error
This is the asynchronous version of
accept.
- public Socket accept_socket (out unowned Object? source_object = null, Cancellable? cancellable = null) throws Error
Blocks waiting for a client to connect to any of the sockets added to
the listener.
- public async Socket accept_socket_async (Cancellable? cancellable = null, out unowned Object? source_object = null) throws Error
- public bool add_address (SocketAddress address, SocketType type, SocketProtocol protocol, Object? source_object, out SocketAddress effective_address) throws Error
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.
- public uint16 add_any_inet_port (Object? source_object) throws Error
Listens for TCP connections on any available port number for both IPv6
and IPv4 (if each is available).
- public bool add_inet_port (uint16 port, Object? source_object) throws Error
Helper function for
add_address that creates a TCP/IP socket listening on IPv4 and IPv6
(if supported) on the specified port on all interfaces.
- public bool add_socket (Socket socket, Object? source_object) throws Error
Adds socket to the set of sockets that we try to accept
new clients from.
- public virtual void changed ()
virtual method called when the set of socket listened to changes
- public void close ()
Closes all the sockets in the listener.
- public void set_backlog (int listen_backlog)
Sets the listen backlog on the sockets in the listener.
Signals:
Inherited Members:
All known members inherited from class GLib.Object