/echo_server

TCP Echo Server '\n'

Primary LanguagePython

Echo Server

Build Status Code Climate Issue Count

Description

The following project implements a TCP socket server that replies to a client everytime it gets a '\n' (configurable, defaults to '\n'), with the sequence of messages received until then.
The server implements a connection timeout handler, so that connections idle more than this threshold get disconnected and cleaned from the system (configurable, defaults to 20s). This means that if a connected socket is not emiting for more than the threshold defined, the connection will be closed in order to flush resources.

Tests

To run the tests just execute:

python tests/test_multiple_connections.py

Install & Run

The steps to use the application.

Install

sudo python setup.py build install

Run

python -m echo_server [options]

Where the options are:

"-v", "--verbose" - Set the loog level to 'DEBUG'.
"-p", "--port" - Set server port. Defaults to 10000
"-t", "--timeout" - Set server socket timeout. Defaults to 0s
"-x", "--max-connections" - Set server maximum connections. Defaults to 5
"-m", "--max-connection-timeout" - Set server maximum time for an active connection. Defaults to 20s
"-b", "--buffer" - Set server buffer length. Defaults to 1024
"-c", "--trigger" - Set server response trigger. Defaults to '\n'

telnet 127.0.0.1 10000