gio.socket_listener

Module for SocketListener class

Types 3

A gio.socket_listener.SocketListener 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 gio.socket_listener.SocketListener.addAddress and gio.socket_listener.SocketListener.addInetPort. These will be listened on until gio.socket_listener.SocketListener.close is called. Dropping your final reference to the gio.socket_listener.SocketListener will not cause gio.socket_listener.SocketListener.close to be called implicitly, as some references to the gio.socket_listener.SocketListener may be held internally.

If you want to implement a network server, also look at gio.socket_service.SocketService and gio.threaded_socket_service.ThreadedSocketService which are subclasses of gio.socket_listener.SocketListener that make this even easier.

Methods
GType _gType() @property
SocketListener self()Returns `this`, for use in `with` statements.
SocketListenerGidBuilder builder()Get builder for [gio.socket_listener.SocketListener] Returns: New builder object
int listenBacklog() @propertyGet `listenBacklog` property. Returns: The number of outstanding connections in the listen queue.
void listenBacklog(int propval) @propertySet `listenBacklog` property. Params: propval = The number of outstanding connections in the listen queue.
gio.socket_connection.SocketConnection accept(out gobject.object.ObjectWrap sourceObject, gio.cancellable.Cancellable cancellable = null)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.
void acceptAsync(gio.cancellable.Cancellable cancellable = null, gio.types.AsyncReadyCallback callback = null)This is the asynchronous version of [gio.socket_listener.SocketListener.accept].
gio.socket_connection.SocketConnection acceptFinish(gio.async_result.AsyncResult result, out gobject.object.ObjectWrap sourceObject)Finishes an async accept operation. See [gio.socket_listener.SocketListener.acceptAsync]
gio.socket.Socket acceptSocket(out gobject.object.ObjectWrap sourceObject, gio.cancellable.Cancellable cancellable = null)Blocks waiting for a client to connect to any of the sockets added to the listener. Returns the #GSocket that was accepted.
void acceptSocketAsync(gio.cancellable.Cancellable cancellable = null, gio.types.AsyncReadyCallback callback = null)This is the asynchronous version of [gio.socket_listener.SocketListener.acceptSocket].
gio.socket.Socket acceptSocketFinish(gio.async_result.AsyncResult result, out gobject.object.ObjectWrap sourceObject)Finishes an async accept operation. See [gio.socket_listener.SocketListener.acceptSocketAsync]
bool addAddress(gio.socket_address.SocketAddress address, gio.types.SocketType type, gio.types.SocketProtocol protocol, gobject.object.ObjectWrap sourceObject, out gio.socket_address.SocketAddress effectiveAddress)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.
ushort addAnyInetPort(gobject.object.ObjectWrap sourceObject = null)Listens for TCP connections on any available port number for both IPv6 and IPv4 (if each is available).
bool addInetPort(ushort port, gobject.object.ObjectWrap sourceObject = null)Helper function for [gio.socket_listener.SocketListener.addAddress] that creates a TCP/IP socket listening on IPv4 and IPv6 (if supported) on the specified port on all interfaces.
bool addSocket(gio.socket.Socket socket, gobject.object.ObjectWrap sourceObject = null)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.
void close()Closes all the sockets in the listener.
void setBacklog(int listenBacklog)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 [gio.socket_listener.Socke...
gulong connectEvent(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == gio.types.SocketListenerEvent))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gio.socket.Socket))) && (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : gio.socket_listener.SocketListener))) && Parameters!T.length < 4)Connect to `Event` signal.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a new #GSocketListener with no sockets to listen for. New listeners can be added with e.g. [gio.socket_listener.SocketListener.addAddress] or [gio.socket_listener.SocketListener.addInetPort...

Fluent builder implementation template for gio.socket_listener.SocketListener

Methods
T listenBacklog(int propval)Set `listenBacklog` property. Params: propval = The number of outstanding connections in the listen queue. Returns: Builder instance for fluent chaining