Class

GioSocketListener

Description [src]

class Gio.SocketListener : GObject.Object {
  parent_instance: GObject,
  priv: GSocketListenerPrivate*
}

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 g_socket_listener_add_address() and g_socket_listener_add_inet_port(). These will be listened on until g_socket_listener_close() is called. Dropping your final reference to the GSocketListener will not cause g_socket_listener_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 GSocketService and GThreadedSocketService which are subclasses of GSocketListener that make this even easier.

Available since:2.22

Hierarchy

hierarchy this GSocketListener ancestor_0 GObject ancestor_0--this

Ancestors

Constructors

g_socket_listener_new

Creates a new GSocketListener with no sockets to listen for. New listeners can be added with e.g. g_socket_listener_add_address() or g_socket_listener_add_inet_port().

Available since: 2.22

Instance methods

g_socket_listener_accept

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.

Available since: 2.22

g_socket_listener_accept_async

This is the asynchronous version of g_socket_listener_accept().

Available since: 2.22

g_socket_listener_accept_finish

Finishes an async accept operation. See g_socket_listener_accept_async()

Available since: 2.22

g_socket_listener_accept_socket

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

Available since: 2.22

g_socket_listener_accept_socket_async

This is the asynchronous version of g_socket_listener_accept_socket().

Available since: 2.22

g_socket_listener_accept_socket_finish

Finishes an async accept operation. See g_socket_listener_accept_socket_async()

Available since: 2.22

g_socket_listener_add_address

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.

Available since: 2.22

g_socket_listener_add_any_inet_port

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

Available since: 2.24

g_socket_listener_add_inet_port

Helper function for g_socket_listener_add_address() that creates a TCP/IP socket listening on IPv4 and IPv6 (if supported) on the specified port on all interfaces.

Available since: 2.22

g_socket_listener_add_socket

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.

Available since: 2.22

g_socket_listener_close

Closes all the sockets in the listener.

Available since: 2.22

g_socket_listener_set_backlog

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 g_socket_listener_add_inet_port()) to be effective.

Available since: 2.22

Methods inherited from GObject (43)

Properties

Gio.SocketListener:listen-backlog
No description available.

Signals

Gio.SocketListener::event

Emitted when listeners activity on socket changes state. Note that when listener is used to listen on both IPv4 and IPv6, a separate set of signals will be emitted for each, and the order they happen in is undefined.

Available since: 2.46

Signals inherited from GObject (1)

Class structure

struct GioSocketListenerClass {
  GObjectClass parent_class;
  void (* changed) (
    GSocketListener* listener
  );
  void (* event) (
    GSocketListener* listener,
    GSocketListenerEvent event,
    GSocket* socket
  );
  void (* _g_reserved2) (
void
  );
  void (* _g_reserved3) (
void
  );
  void (* _g_reserved4) (
void
  );
  void (* _g_reserved5) (
void
  );
  void (* _g_reserved6) (
void
  );
  
}
Class members
parent_class
GObjectClass
  No description available.
changed
void (* changed) (
    GSocketListener* listener
  )
  No description available.
event
void (* event) (
    GSocketListener* listener,
    GSocketListenerEvent event,
    GSocket* socket
  )
  No description available.
_g_reserved2
void (* _g_reserved2) (
void
  )
  No description available.
_g_reserved3
void (* _g_reserved3) (
void
  )
  No description available.
_g_reserved4
void (* _g_reserved4) (
void
  )
  No description available.
_g_reserved5
void (* _g_reserved5) (
void
  )
  No description available.
_g_reserved6
void (* _g_reserved6) (
void
  )
  No description available.

Virtual methods

Gio.SocketListenerClass.changed
No description available.
Gio.SocketListenerClass.event
No description available.