def __init__(self, reactor, host, port, timeout=30, bindAddress=None,
attemptDelay=None):
"""
Create a L{HostnameEndpoint}.
@param reactor: The reactor to use for connections and delayed calls.
@type reactor: provider of L{IReactorTCP}, L{IReactorTime} and either
L{IReactorPluggableNameResolver} or L{IReactorPluggableResolver}.
@param host: A hostname to connect to.
@type host: L{bytes} or L{unicode}
@param port: The port number to connect to.
@type port: L{int}
@param timeout: For each individual connection attempt, the number of
seconds to wait before assuming the connection has failed.
@type timeout: L{int}
@param bindAddress: the local address of the network interface to make
the connections from.
@type bindAddress: L{bytes}
@param attemptDelay: The number of seconds to delay between connection
attempts.
@type attemptDelay: L{float}
@see: L{twisted.internet.interfaces.IReactorTCP.connectTCP}
"""
self._reactor = reactor
[self._badHostname, self._hostBytes, self._hostText] = (
self._hostAsBytesAndText(host)
)
self._hostStr = self._hostBytes if bytes is str else self._hostText
self._port = port
self._timeout = timeout
self._bindAddress = bindAddress
if attemptDelay is None:
attemptDelay = self._DEFAULT_ATTEMPT_DELAY
self._attemptDelay = attemptDelay
评论列表
文章目录