Parameters: | loop (Loop) – loop object where this handle runs (accessible through TCP.loop). |
---|
The TCP handle provides asynchronous TCP functionality both as a client and server.
Parameters: |
|
---|
Bind to the specified IP address and port.
Parameters: |
|
---|
Start listening for new connections.
Callback signature: callback(tcp_handle, error).
Parameters: | client (object) – Client object where to accept the connection. |
---|
Accept a new incoming connection which was pending. This function needs to be called in the callback given to the listen() function.
Parameters: |
|
---|
Initiate a client connection to the specified IP address and port.
Callback signature: callback(tcp_handle, error).
Parameters: | fd (int) – File descriptor to be opened. |
---|
Open the given file descriptor (or SOCKET in Windows) as a TCP handle.
Return tuple containing IP address and port of the local socket. In case of IPv6 sockets, it also returns the flow info and scope ID (a 4 element tuple).
Return tuple containing IP address and port of the remote endpoint’s socket. In case of IPv6 sockets, it also returns the flow info and scope ID (a 4 element tuple).
Parameters: | callback (callable) – Callback to be called after shutdown has been performed. |
---|
Shutdown the outgoing (write) direction of the TCP connection.
Callback signature: callback(tcp_handle, error).
Parameters: |
|
---|
Write data on the TCP connection.
Callback signature: callback(tcp_handle, error).
Parameters: |
|
---|
Write data on the TCP connection.
Callback signature: callback(tcp_handle, error).
Parameters: | callback (callable) – Callback to be called when data is read from the remote endpoint. |
---|
Start reading for incoming data from the remote endpoint.
Callback signature: callback(tcp_handle, data, error).
Stop reading data from the remote endpoint.
Parameters: | enable (boolean) – Enable / disable nodelay option. |
---|
Enable / disable Nagle’s algorithm.
Parameters: |
|
---|
Enable / disable TCP keep-alive.
Parameters: | enable (boolean) – Enable / disable simultaneous accepts. |
---|
Enable / disable simultaneous asynchronous accept requests that are queued by the operating system when listening for new tcp connections. This setting is used to tune a tcp server for the desired performance. Having simultaneous accepts can significantly improve the rate of accepting connections (which is why it is enabled by default) but may lead to uneven load distribution in multi-process setups.
Read only
Returns the size of the write queue.
Read only
Indicates if this handle is readable.
Read only
Indicates if this handle is writable.