SocketAddressEnumerator

class SocketAddressEnumerator(**properties: Any)

Superclasses: Object

Subclasses: ProxyAddressEnumerator

GSocketAddressEnumerator is an enumerator type for SocketAddress instances. It is returned by enumeration functions such as 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 next_async and next_finish should be used where possible.

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

Methods

class SocketAddressEnumerator
next(cancellable: Cancellable | None = 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 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 next() will return an appropriate error in *error. However, if the first call to 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(cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None

Asynchronously retrieves the next SocketAddress from enumerator and then calls callback, which must call 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 AsyncReadyCallback to call when the request is satisfied

  • user_data – the data to pass to callback function

next_finish(result: AsyncResult) SocketAddress | None

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

Parameters:

result – a AsyncResult

Virtual Methods

class SocketAddressEnumerator
do_next(cancellable: Cancellable | None = 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 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 next() will return an appropriate error in *error. However, if the first call to 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(cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None

Asynchronously retrieves the next SocketAddress from enumerator and then calls callback, which must call 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 AsyncReadyCallback to call when the request is satisfied

  • user_data – the data to pass to callback function

do_next_finish(result: AsyncResult) SocketAddress | None

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

Parameters:

result – a AsyncResult

Fields

class SocketAddressEnumerator
parent_instance