Implements interfaces: twisted.internet.interfaces.IStreamClientEndpoint

A name-based endpoint that connects to the fastest amongst the resolved host addresses.

Method __init__ Create a HostnameEndpoint.
Method connect Attempts a connection to each address returned by gai, and returns a connection which is established first.
Class Variable _DEFAULT_ATTEMPT_DELAY The default time to use between attempts, in seconds, when no attemptDelay is given to HostnameEndpoint.__init__.
Instance Variable _hostText the textual representation of the hostname passed to the constructor. Used to pass to the reactor's hostname resolver. (type: unicode)
Instance Variable _hostBytes the encoded bytes-representation of the hostname passed to the constructor. Used to construct the HostnameAddress associated with this endpoint. (type: bytes)
Instance Variable _hostStr the native-string representation of the hostname passed to the constructor, used for exception construction (type: native str)
Instance Variable _badHostname a flag - hopefully false! - indicating that an invalid hostname was passed to the constructor. This might be a textual hostname that isn't valid IDNA, or non-ASCII bytes. (type: bool)
Static Method _hostAsBytesAndText No summary
_DEFAULT_ATTEMPT_DELAY =
The default time to use between attempts, in seconds, when no attemptDelay is given to HostnameEndpoint.__init__.
_hostText =
the textual representation of the hostname passed to the constructor. Used to pass to the reactor's hostname resolver. (type: unicode)
_hostBytes =
the encoded bytes-representation of the hostname passed to the constructor. Used to construct the HostnameAddress associated with this endpoint. (type: bytes)
_hostStr =
the native-string representation of the hostname passed to the constructor, used for exception construction (type: native str)
_badHostname =
a flag - hopefully false! - indicating that an invalid hostname was passed to the constructor. This might be a textual hostname that isn't valid IDNA, or non-ASCII bytes. (type: bool)
def __init__(self, reactor, host, port, timeout=30, bindAddress=None, attemptDelay=None): (source)

Create a HostnameEndpoint.

ParametersreactorThe reactor to use for connections and delayed calls. (type: provider of IReactorTCP, IReactorTime and either IReactorPluggableNameResolver or IReactorPluggableResolver.)
hostA hostname to connect to. (type: bytes or unicode)
portThe port number to connect to. (type: int)
timeoutFor each individual connection attempt, the number of seconds to wait before assuming the connection has failed. (type: int)
bindAddressthe local address of the network interface to make the connections from. (type: bytes)
attemptDelayThe number of seconds to delay between connection attempts. (type: float)
See Alsotwisted.internet.interfaces.IReactorTCP.connectTCP
@staticmethod
def _hostAsBytesAndText(host): (source)

For various reasons (documented in the @ivar's in the class docstring) we need both a textual and a binary representation of the hostname given to the constructor. For compatibility and convenience, we accept both textual and binary representations of the hostname, save the form that was passed, and convert into the other form. This is mostly just because HostnameAddress chose somewhat poorly to define its attribute as bytes; hopefully we can find a compatible way to clean this up in the future and just operate in terms of text internally.

ParametershostA hostname to convert. (type: bytes or str)
Returnsa 3-tuple of (invalid, bytes, text) where invalid is a boolean indicating the validity of the hostname, bytes is a binary representation of host, and text is a textual representation of host.
def connect(self, protocolFactory): (source)

Attempts a connection to each address returned by gai, and returns a connection which is established first.

API Documentation for Twisted, generated by pydoctor at 2017-02-11 20:06:04.