Method

GioSocketListeneradd_address

since: 2.22

Declaration [src]

gboolean
g_socket_listener_add_address (
  GSocketListener* listener,
  GSocketAddress* address,
  GSocketType type,
  GSocketProtocol protocol,
  GObject* source_object,
  GSocketAddress** effective_address,
  GError** error
)

Description [src]

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.

Note that adding an IPv6 address, depending on the platform, may or may not result in a listener that also accepts IPv4 connections. For more deterministic behavior, see g_socket_listener_add_inet_port().

source_object will be passed out in the various calls to accept to identify this particular source, which is useful if you’re listening on multiple addresses and do different things depending on what address is connected to.

If successful and effective_address is non-NULL then it will be set to the address that the binding actually occurred at. This is helpful for determining the port number that was used for when requesting a binding to port 0 (ie: “any port”). This address, if requested, belongs to the caller and must be freed.

Call g_socket_listener_close() to stop listening on address; this will not be done automatically when you drop your final reference to listener, as references may be held internally.

Available since: 2.22

Parameters

address

Type: GSocketAddress

A GSocketAddress.

The data is owned by the caller of the method.
type

Type: GSocketType

A GSocketType.

protocol

Type: GSocketProtocol

A GSocketProtocol.

source_object

Type: GObject

Optional GObject identifying this source.

The argument can be NULL.
The data is owned by the caller of the method.
effective_address

Type: GSocketAddress

Location to store the address that was bound to, or NULL.

The argument will be set by the function.
The argument can be NULL.
The caller of the method takes ownership of the returned data, and is responsible for freeing it.
error

Type: GError **

The return location for a recoverable error.

The argument can be NULL.
If the return location is not NULL, then you must initialize it to a NULL GError*.
The argument will be left initialized to NULL by the method if there are no errors.
In case of error, the argument will be set to a newly allocated GError; the caller will take ownership of the data, and be responsible for freeing it.

Return value

Type: gboolean

TRUE on success, FALSE on error.