tornado.tcpclient — IOStream connection factory¶
A non-blocking TCP connection factory.
-
class
tornado.tcpclient.TCPClient(resolver=None, io_loop=None)[source]¶ A non-blocking TCP connection factory.
Changed in version 4.1: The
io_loopargument is deprecated.-
connect(host, port, af=<AddressFamily.AF_UNSPEC: 0>, ssl_options=None, max_buffer_size=None, source_ip=None, source_port=None)[source]¶ Connect to the given host and port.
Asynchronously returns an
IOStream(orSSLIOStreamifssl_optionsis not None).Using the
source_ipkwarg, one can specify the source IP address to use when establishing the connection. In case the user needs to resolve and use a specific interface, it has to be handled outside of Tornado as this depends very much on the platform.Similarly, when the user requires a certain source port, it can be specified using the
source_portarg.Changed in version 4.5: Added the
source_ipandsource_portarguments.
-