:py:mod:`socha.api.networking.network_socket` ============================================= .. py:module:: socha.api.networking.network_socket Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: socha.api.networking.network_socket.NetworkSocket .. py:class:: NetworkSocket(host='localhost', port=13050, timeout=0.1) This class represents a network socket that can be used to connect to a server, send data, and receive data. .. py:method:: connect() Connects the socket to the specified host and port. Sets the timeout value and sets the 'connected' attribute to True. .. py:method:: close() Closes the socket and sets the 'connected' attribute to False. .. py:method:: send(data: bytes) Sends the specified data (in bytes) to the connected server. .. py:method:: receive() -> Union[bytes, None] Attempts to receive data from the server. The received data is processed using a regular expression to extract complete messages. If a complete message is found, it is returned as bytes and removed from the buffer. If no complete message is found, None is returned. If a timeout occurs or a connection reset error is encountered, the socket is closed and None is returned.