Public Member Functions | |
def | __init__ |
def | close_fd |
def | connect |
def | fileno |
def | get_fd_error |
def | read_from_fd |
def | set_nodelay |
def | start_tls |
def | write_to_fd |
Public Attributes | |
error | |
socket | |
Private Member Functions | |
def | _handle_connect |
Private Attributes | |
_close_callback | |
_connect_callback | |
_connect_future | |
_connecting |
Definition at line 887 of file iostream.py.
def tornado.iostream.IOStream.__init__ | ( | self, | |
socket, | |||
args, | |||
kwargs | |||
) |
Definition at line 928 of file iostream.py.
def tornado.iostream.IOStream._handle_connect | ( | self | ) | [private] |
Reimplemented in tornado.iostream.SSLIOStream.
Definition at line 1084 of file iostream.py.
def tornado.iostream.IOStream.close_fd | ( | self | ) |
Closes the file underlying this stream. ``close_fd`` is called by `BaseIOStream` and should not be called elsewhere; other users should call `close` instead.
Reimplemented from tornado.iostream.BaseIOStream.
Definition at line 936 of file iostream.py.
def tornado.iostream.IOStream.connect | ( | self, | |
address, | |||
callback = None , |
|||
server_hostname = None |
|||
) |
Connects the socket to a remote address without blocking. May only be called if the socket passed to the constructor was not previously connected. The address parameter is in the same format as for `socket.connect <socket.socket.connect>` for the type of socket passed to the IOStream constructor, e.g. an ``(ip, port)`` tuple. Hostnames are accepted here, but will be resolved synchronously and block the IOLoop. If you have a hostname instead of an IP address, the `.TCPClient` class is recommended instead of calling this method directly. `.TCPClient` will do asynchronous DNS resolution and handle both IPv4 and IPv6. If ``callback`` is specified, it will be called with no arguments when the connection is completed; if not this method returns a `.Future` (whose result after a successful connection will be the stream itself). If specified, the ``server_hostname`` parameter will be used in SSL connections for certificate validation (if requested in the ``ssl_options``) and SNI (if supported; requires Python 3.2+). Note that it is safe to call `IOStream.write <BaseIOStream.write>` while the connection is pending, in which case the data will be written as soon as the connection is ready. Calling `IOStream` read methods before the socket is connected works on some platforms but is non-portable. .. versionchanged:: 4.0 If no callback is given, returns a `.Future`.
Reimplemented in tornado.iostream.SSLIOStream.
Definition at line 961 of file iostream.py.
def tornado.iostream.IOStream.fileno | ( | self | ) |
Returns the file descriptor for this stream.
Reimplemented from tornado.iostream.BaseIOStream.
Definition at line 933 of file iostream.py.
def tornado.iostream.IOStream.get_fd_error | ( | self | ) |
Returns information about any error on the underlying file. This method is called after the `.IOLoop` has signaled an error on the file descriptor, and should return an Exception (such as `socket.error` with additional information, or None if no such information is available.
Reimplemented from tornado.iostream.BaseIOStream.
Definition at line 940 of file iostream.py.
def tornado.iostream.IOStream.read_from_fd | ( | self | ) |
Attempts to read from the underlying file. Returns ``None`` if there was nothing to read (the socket returned `~errno.EWOULDBLOCK` or equivalent), otherwise returns the data. When possible, should return no more than ``self.read_chunk_size`` bytes at a time.
Reimplemented from tornado.iostream.BaseIOStream.
Reimplemented in tornado.iostream.SSLIOStream.
Definition at line 945 of file iostream.py.
def tornado.iostream.IOStream.set_nodelay | ( | self, | |
value | |||
) |
Sets the no-delay flag for this stream. By default, data written to TCP streams may be held for a time to make the most efficient use of bandwidth (according to Nagle's algorithm). The no-delay flag requests that data be written as soon as possible, even if doing so would consume additional bandwidth. This flag is currently defined only for TCP-based ``IOStreams``. .. versionadded:: 3.1
Reimplemented from tornado.iostream.BaseIOStream.
Definition at line 1107 of file iostream.py.
def tornado.iostream.IOStream.start_tls | ( | self, | |
server_side, | |||
ssl_options = None , |
|||
server_hostname = None |
|||
) |
Convert this `IOStream` to an `SSLIOStream`. This enables protocols that begin in clear-text mode and switch to SSL after some initial negotiation (such as the ``STARTTLS`` extension to SMTP and IMAP). This method cannot be used if there are outstanding reads or writes on the stream, or if there is any data in the IOStream's buffer (data in the operating system's socket buffer is allowed). This means it must generally be used immediately after reading or writing the last clear-text data. It can also be used immediately after connecting, before any reads or writes. The ``ssl_options`` argument may be either a dictionary of options or an `ssl.SSLContext`. If a ``server_hostname`` is given, it will be used for certificate verification (as configured in the ``ssl_options``). This method returns a `.Future` whose result is the new `SSLIOStream`. After this method has been called, any other operation on the original stream is undefined. If a close callback is defined on this stream, it will be transferred to the new stream. .. versionadded:: 4.0
Definition at line 1020 of file iostream.py.
def tornado.iostream.IOStream.write_to_fd | ( | self, | |
data | |||
) |
Attempts to write ``data`` to the underlying file. Returns the number of bytes written.
Reimplemented from tornado.iostream.BaseIOStream.
Definition at line 958 of file iostream.py.
Reimplemented from tornado.iostream.BaseIOStream.
Definition at line 1047 of file iostream.py.
Reimplemented from tornado.iostream.BaseIOStream.
Definition at line 993 of file iostream.py.
Reimplemented from tornado.iostream.BaseIOStream.
Definition at line 993 of file iostream.py.
tornado::iostream.IOStream::_connecting [private] |
Reimplemented from tornado.iostream.BaseIOStream.
Definition at line 993 of file iostream.py.
Reimplemented from tornado.iostream.BaseIOStream.
Definition at line 1084 of file iostream.py.
Reimplemented in tornado.iostream.SSLIOStream.
Definition at line 928 of file iostream.py.