SocketAddressEnumerator#
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
- do_next(self, cancellable: Cancellable | None = None) SocketAddress | None#
- Parameters:
cancellable
- do_next_async(self, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
- Parameters:
cancellable
callback
user_data
- do_next_finish(self, result: AsyncResult) SocketAddress | None#
- Parameters:
result
- next(cancellable: Cancellable | None = None) SocketAddress | None#
Retrieves the next
SocketAddressfromenumerator. Note that this may block for some amount of time. (Eg, aNetworkAddressmay need to do a DNS lookup before it can return an address.) Usenext_async()if you need to avoid blocking.If
enumeratoris expected to yield addresses, but for some reason is unable to (eg, because of a DNS error), then the first call tonext()will return an appropriate error inerror. However, if the first call tonext()succeeds, then any further internal errors (other thancancellablebeing triggered) will be ignored.- Parameters:
cancellable – optional
Cancellableobject,Noneto ignore.
- async next_async(self) SocketAddress | None#
This is the awaitable version of
next_async().
- next_async(cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
Asynchronously retrieves the next
SocketAddressfromenumeratorand then callscallback, which must callnext_finish()to get the result.It is an error to call this multiple times before the previous callback has finished.
- Parameters:
cancellable – optional
Cancellableobject,Noneto ignore.callback – a
AsyncReadyCallbackto call when the request is satisfieduser_data – the data to pass to callback function
- next_finish(result: AsyncResult) SocketAddress | None#
Retrieves the result of a completed call to
next_async(). Seenext()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
SocketAddressfromenumerator. Note that this may block for some amount of time. (Eg, aNetworkAddressmay need to do a DNS lookup before it can return an address.) Usenext_async()if you need to avoid blocking.If
enumeratoris expected to yield addresses, but for some reason is unable to (eg, because of a DNS error), then the first call tonext()will return an appropriate error inerror. However, if the first call tonext()succeeds, then any further internal errors (other thancancellablebeing triggered) will be ignored.- Parameters:
cancellable – optional
Cancellableobject,Noneto ignore.
- do_next_async(cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
Asynchronously retrieves the next
SocketAddressfromenumeratorand then callscallback, which must callnext_finish()to get the result.It is an error to call this multiple times before the previous callback has finished.
- Parameters:
cancellable – optional
Cancellableobject,Noneto ignore.callback – a
AsyncReadyCallbackto call when the request is satisfieduser_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(). Seenext()for more information about error handling.- Parameters:
result – a
AsyncResult
Fields#
- class SocketAddressEnumerator
- parent_instance#