Hash server:
- 3 background threads to calculate hashes
- main thread accepting connections and passing sockets to background threads
- per socket server uses 2 x 1024 bytes for a buffer
Implemented on top of Boost Asio and xxHash (see Dockerfile):
-
libxxhash-dev
-
GitHub template zethon/CCCBTemplate
TODO:
- very slow Integer to Hex string conversion (std::stream, setfill) - 50% of server time
- segfaults in xxHash on big input
Checkout the code, create Docker container, start Docker service listening TCP port 1234:
git clone https://github.com/makru86/tcp-hash.git
cd tcp-hash
make docker-serve # or make serve
See tools/tcp_hash_prototype.sh. See tools/client.sh.
Keep connection open, exit by Ctrl-C:
netcat localhost 1234
Hello, world!
>>> 0x2c6b514f4f9e3e3c
dd
>>> 0x3fa6d80d3a0da668
netcat-openbsd (nc) example, closing connection after receiving response:
echo "Hello, world!" | nc -W 1 localhost 1234
>>> 0x2c6b514f4f9e3e3c
nc
option -W recvlimit
:
Terminate after receiving recvlimit packets from the network.
make build # or make docker-build
make test # or make docker-test
make formatted
make tidy
env CODE_COVERAGE=ON make up
make coverage-report
>>> Generating coverage report...
>>> lines: 54.9% (79 out of 144)
>>> branches: 36.6% (232 out of 634)
>>> build/coverage.xml