Socket.accept

Accept incoming connections on a connection-based socket. This removes the first outstanding connection request from the listening socket and creates a #GSocket object for it.

The socket must be bound to a local address with [gio.socket.Socket.bind] and must be listening for incoming connections ([gio.socket.Socket.listen]).

If there are no outstanding connections then the operation will block or return [gio.types.IOErrorEnum.WouldBlock] if non-blocking I/O is enabled. To be notified of an incoming connection, wait for the [glib.types.IOCondition.In] condition.

Parameters

cancellablea [gio.cancellable.Cancellable] or null

Returns

a new #GSocket, or null on error.

Free the returned object with [gobject.object.ObjectWrap.unref].

Throws

[ErrorWrap]