AcceptConnection

class mtf.network_port.tls.tls_helpers.AcceptConnection

Object used to accept an incoming TCP connection from a client.

This class listens on a specified hostname and port, accepts a connection from a client, and sets up the necessary configurations for further communication.

__init__(hostname: str, port: int, version: tuple, timeout: float)

Initializes the server-side connection parameters.

Parameters:
  • hostname (str) – The hostname or IP address to bind to for accepting connections.

  • port (int) – The TCP port number to listen on for incoming connections.

  • version (tuple(int, int)) – The protocol version used in the TLS record layer for the initial handshake messages. Defaults to (3, 0).

  • timeout (float) – The timeout in seconds for accepting the connection and subsequent read/write operations. Defaults to 5 seconds.

process(state: ConnectionState)

Listens for and accepts an incoming connection from a client.

This method creates a TCP socket, binds it to the specified hostname and port, and listens for incoming connection requests. Upon accepting a connection, it disables Nagle’s algorithm, wraps the socket in a BufferedSocket for optimized I/O, and sets up a Defragmenter for handling message fragmentation.

Parameters:

state – An object representing the current state of the connection, where the accepted socket and protocol version will be stored.

cleanup()

Cleans up resources such as sockets to prevent resource leaks.

add_child(child)

Sets the parameter as the child of the node

Returns:

the child node

get_all_siblings()

Return iterator with all siblings of node

Return type:

iterator

is_command()

Define object as a command node.

is_expect()

Define object as a command node.

is_generator()

Define object as a command node.