SocketListener

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.

Constructors

this
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.

Members

Functions

accept
gio.socket_connection.SocketConnection accept(gobject.object.ObjectG sourceObject, gio.cancellable.Cancellable cancellable)

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.

acceptAsync
void acceptAsync(gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

This is the asynchronous version of gio.socket_listener.SocketListener.accept.

acceptFinish
gio.socket_connection.SocketConnection acceptFinish(gio.async_result.AsyncResult result, gobject.object.ObjectG sourceObject)

Finishes an async accept operation. See gio.socket_listener.SocketListener.acceptAsync

acceptSocket
gio.socket.Socket acceptSocket(gobject.object.ObjectG sourceObject, gio.cancellable.Cancellable cancellable)

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

acceptSocketAsync
void acceptSocketAsync(gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

This is the asynchronous version of gio.socket_listener.SocketListener.acceptSocket.

acceptSocketFinish
gio.socket.Socket acceptSocketFinish(gio.async_result.AsyncResult result, gobject.object.ObjectG sourceObject)

Finishes an async accept operation. See gio.socket_listener.SocketListener.acceptSocketAsync

addAddress
bool addAddress(gio.socket_address.SocketAddress address, gio.types.SocketType type, gio.types.SocketProtocol protocol, gobject.object.ObjectG sourceObject, 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.

addAnyInetPort
ushort addAnyInetPort(gobject.object.ObjectG sourceObject)

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

addInetPort
bool addInetPort(ushort port, gobject.object.ObjectG sourceObject)

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.

addSocket
bool addSocket(gio.socket.Socket socket, gobject.object.ObjectG sourceObject)

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.

close
void close()

Closes all the sockets in the listener.

connectEvent
ulong connectEvent(T callback, Flag!"After" after)

Connect to Event signal.

setBacklog
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.SocketListener.addInetPort) to be effective.

Inherited Members

From ObjectG

setGObject
void setGObject(void* cObj, Flag!"Take" take)

Set the GObject of a D ObjectG wrapper.

cPtr
void* cPtr(Flag!"Dup" dup)

Get a pointer to the underlying C object.

ref_
void* ref_(void* gObj)

Calls g_object_ref() on a GObject.

unref
unref(void* gObj)

Calls g_object_unref() on a GObject.

getType
GType getType()

Get the GType of an object.

gType
GType gType [@property getter]

GObject GType property.

self
ObjectG self()

Convenience method to return this cast to a type. For use in D with statements.

getDObject
T getDObject(void* cptr, Flag!"Take" take)

Template to get the D object from a C GObject and cast it to the given D object type.

connectSignalClosure
ulong connectSignalClosure(string signalDetail, DClosure closure, Flag!"After" after)

Connect a D closure to an object signal.

setProperty
void setProperty(string propertyName, T val)

Template for setting a GObject property.

getProperty
T getProperty(string propertyName)

Template for getting a GObject property.

compatControl
size_t compatControl(size_t what, void* data)
bindProperty
gobject.binding.Binding bindProperty(string sourceProperty, gobject.object.ObjectG target, string targetProperty, gobject.types.BindingFlags flags)

Creates a binding between source_property on source and target_property on target.

bindPropertyFull
gobject.binding.Binding bindPropertyFull(string sourceProperty, gobject.object.ObjectG target, string targetProperty, gobject.types.BindingFlags flags, gobject.closure.Closure transformTo, gobject.closure.Closure transformFrom)

Creates a binding between source_property on source and target_property on target, allowing you to set the transformation functions to be used by the binding.

forceFloating
void forceFloating()

This function is intended for #GObject implementations to re-enforce a floating[floating-ref] object reference. Doing this is seldom required: all #GInitiallyUnowneds are created with a floating reference which usually just needs to be sunken by calling gobject.object.ObjectG.refSink.

freezeNotify
void freezeNotify()

Increases the freeze count on object. If the freeze count is non-zero, the emission of "notify" signals on object is stopped. The signals are queued until the freeze count is decreased to zero. Duplicate notifications are squashed so that at most one #GObject::notify signal is emitted for each property modified while the object is frozen.

getData
void* getData(string key)

Gets a named field from the objects table of associations (see gobject.object.ObjectG.setData).

getProperty
void getProperty(string propertyName, gobject.value.Value value)

Gets a property of an object.

getQdata
void* getQdata(glib.types.Quark quark)

This function gets back user data pointers stored via gobject.object.ObjectG.setQdata.

getv
void getv(string[] names, gobject.value.Value[] values)

Gets n_properties properties for an object. Obtained properties will be set to values. All properties must be valid. Warnings will be emitted and undefined behaviour may result if invalid properties are passed in.

isFloating
bool isFloating()

Checks whether object has a floating[floating-ref] reference.

notify
void notify(string propertyName)

Emits a "notify" signal for the property property_name on object.

notifyByPspec
void notifyByPspec(gobject.param_spec.ParamSpec pspec)

Emits a "notify" signal for the property specified by pspec on object.

refSink
gobject.object.ObjectG refSink()

Increase the reference count of object, and possibly remove the floating[floating-ref] reference, if object has a floating reference.

runDispose
void runDispose()

Releases all references to other objects. This can be used to break reference cycles.

setData
void setData(string key, void* data)

Each object carries around a table of associations from strings to pointers. This function lets you set an association.

setProperty
void setProperty(string propertyName, gobject.value.Value value)

Sets a property on an object.

stealData
void* stealData(string key)

Remove a specified datum from the object's data associations, without invoking the association's destroy handler.

stealQdata
void* stealQdata(glib.types.Quark quark)

This function gets back user data pointers stored via gobject.object.ObjectG.setQdata and removes the data from object without invoking its destroy() function (if any was set). Usually, calling this function is only required to update user data pointers with a destroy notifier, for example:

thawNotify
void thawNotify()

Reverts the effect of a previous call to gobject.object.ObjectG.freezeNotify. The freeze count is decreased on object and when it reaches zero, queued "notify" signals are emitted.

watchClosure
void watchClosure(gobject.closure.Closure closure)

This function essentially limits the life time of the closure to the life time of the object. That is, when the object is finalized, the closure is invalidated by calling gobject.closure.Closure.invalidate on it, in order to prevent invocations of the closure with a finalized (nonexisting) object. Also, gobject.object.ObjectG.ref_ and gobject.object.ObjectG.unref are added as marshal guards to the closure, to ensure that an extra reference count is held on object during invocation of the closure. Usually, this function will be called on closures that use this object as closure data.

connectNotify
ulong connectNotify(string detail, T callback, Flag!"After" after)

Connect to Notify signal.