Skip to content

Gio.SocketAddressEnumerator

class — extends GObject.Object

GSocketAddressEnumerator is an enumerator type for SocketAddress instances. It is returned by enumeration functions such as SocketConnectable.enumerate, which returns a GSocketAddressEnumerator to list each SocketAddress which could be used to connect to that SocketConnectable.

Enumeration is typically a blocking operation, so the asynchronous methods SocketAddressEnumerator.next_async and SocketAddressEnumerator.next_finish should be used where possible.

Each GSocketAddressEnumerator can only be enumerated once. Once SocketAddressEnumerator.next has returned NULL, further enumeration with that GSocketAddressEnumerator is not possible, and it can be unreffed.

Methods

next

def next(self, cancellable: Cancellable | None = ...) -> SocketAddress | None

Retrieves the next SocketAddress from enumerator. Note that this may block for some amount of time. (Eg, a NetworkAddress may need to do a DNS lookup before it can return an address.) Use SocketAddressEnumerator.next_async if you need to avoid blocking.

If enumerator is expected to yield addresses, but for some reason is unable to (eg, because of a DNS error), then the first call to SocketAddressEnumerator.next will return an appropriate error in *error. However, if the first call to SocketAddressEnumerator.next succeeds, then any further internal errors (other than cancellable being triggered) will be ignored.

Parameters:

  • cancellable — optional Cancellable object, None to ignore.

next_async

def next_async(self, cancellable: Cancellable | None = ..., callback: Callable[[SocketAddressEnumerator | None, AsyncResult], None] | None = ...) -> None

Asynchronously retrieves the next SocketAddress from enumerator and then calls callback, which must call SocketAddressEnumerator.next_finish to get the result.

It is an error to call this multiple times before the previous callback has finished.

Parameters:

  • cancellable — optional Cancellable object, None to ignore.
  • callback — a GAsyncReadyCallback to call when the request is satisfied

next_finish

def next_finish(self, result: AsyncResult) -> SocketAddress | None

Retrieves the result of a completed call to SocketAddressEnumerator.next_async. See SocketAddressEnumerator.next for more information about error handling.

Parameters:

Virtual methods

do_next

def do_next(self, cancellable: Cancellable | None = ...) -> SocketAddress | None

Retrieves the next SocketAddress from enumerator. Note that this may block for some amount of time. (Eg, a NetworkAddress may need to do a DNS lookup before it can return an address.) Use SocketAddressEnumerator.next_async if you need to avoid blocking.

If enumerator is expected to yield addresses, but for some reason is unable to (eg, because of a DNS error), then the first call to SocketAddressEnumerator.next will return an appropriate error in *error. However, if the first call to SocketAddressEnumerator.next succeeds, then any further internal errors (other than cancellable being triggered) will be ignored.

Parameters:

  • cancellable — optional Cancellable object, None to ignore.

do_next_async

def do_next_async(self, cancellable: Cancellable | None = ..., callback: Callable[[SocketAddressEnumerator | None, AsyncResult], None] | None = ...) -> None

Asynchronously retrieves the next SocketAddress from enumerator and then calls callback, which must call SocketAddressEnumerator.next_finish to get the result.

It is an error to call this multiple times before the previous callback has finished.

Parameters:

  • cancellable — optional Cancellable object, None to ignore.
  • callback — a GAsyncReadyCallback to call when the request is satisfied

do_next_finish

def do_next_finish(self, result: AsyncResult) -> SocketAddress | None

Retrieves the result of a completed call to SocketAddressEnumerator.next_async. See SocketAddressEnumerator.next for more information about error handling.

Parameters: