https://github.com/pc-magas/tcp_command
A minimalistic TCP command Handling Server
https://github.com/pc-magas/tcp_command
learning-by-doing socket tcp
Last synced: 2 months ago
JSON representation
A minimalistic TCP command Handling Server
- Host: GitHub
- URL: https://github.com/pc-magas/tcp_command
- Owner: pc-magas
- License: mit
- Created: 2019-06-15T19:00:29.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-05T20:09:31.000Z (about 5 years ago)
- Last Synced: 2024-04-19T09:56:32.240Z (about 1 year ago)
- Topics: learning-by-doing, socket, tcp
- Language: C++
- Size: 57.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Simplistic Command Server
A simple TCP Server that is able to execute pseudo-commands. By default Listens into localhost and port 7070 (no terminal parameter are provided yet).
I made this kind of server in order to learn better C++.# Build, develop and run unit test
* `make build`: builds the application.
* `make run` : Builds and runs a production-ready binary executable.
* `make debug`: Debugs the application (needs gdb)
* `make test_command_parser_build`: runs the unit test for command parser.
* `make test_command_parser_run`: is running the unit test compiled above.On `make` commands you can provide a parameter `DEBUG` with values either `1` or `0`, `1` indicated that the projhect will be build with the appropriate flags in order to be able to debug it with `g++`.
For unit tests I use the `cxxtestgen` and in Ubuntu GNU/Liux is available via the command:
```
sudo apt install cxxtestgen
```In order to send commands you can utilize the UNIX `nc` command:
```
netcat ^host^ ^port^ <<<$'^command^\n^command^\n...exit\n'
```A toy example of using the netcat is:
```
nc -4 localhost 7070 <<<$'hello\nhello\nexit\n'
```# Command Line arguments and run
The server uses the following mandatory command-line arguments:
* `-h` That the host is specified.
* `-p` That the post is specified.Any executable and usefull binary is build upon `build/release` the unit tests are built in `build/testing` in order to run it from the cli on a console run:
```
./build/release/server -h ^host^ -p ^port^
```# Available commands:
The following commands are available:
* `hello` That returns the message **hello**
* `exit` That indicates the end of the command sequence.Each command is being seperated with `\n`.