https://github.com/ozancansel/imd-srv
A multithreaded and asynchronous TCP server which stores and serves key-value pairs.
https://github.com/ozancansel/imd-srv
asio boost cmake cpp17 networking
Last synced: about 2 months ago
JSON representation
A multithreaded and asynchronous TCP server which stores and serves key-value pairs.
- Host: GitHub
- URL: https://github.com/ozancansel/imd-srv
- Owner: OzanCansel
- License: mit
- Created: 2022-08-17T18:06:48.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-08-25T18:05:39.000Z (almost 3 years ago)
- Last Synced: 2025-02-09T21:43:36.048Z (4 months ago)
- Topics: asio, boost, cmake, cpp17, networking
- Language: C++
- Homepage:
- Size: 38.1 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# imd-srv
A tcp server application which allows clients to `put`, `remove` and `get` desired `key`-`value` pairs which are stored in-memory.It is multithreaded and fully asynchronous server.
- Requires a C++17 compliant compiler
- `asio`, `thread` and `program options` components should be installed on the system.Only tested on Ubuntu 20.04 with GCC 11.2.0 and Boost v1.74
### Synopsis
```console
Allowed options:
--help produce help message
--threads arg (=0) Specify number of executor threads.
--port arg (=9424) Specify port number to listen.
```### Commands
`imd-srv` reads stream line-by-line from its clients and performs required operations if it is a properly constructed command.
All commands are text based and a command starts with `opcode` which is a word such as `put`, `get`, `remove` and ends with `\n` character.#### Put
Puts specified `key` `value` pairs in map.
```console
put
# or responds with one of the errors below :
error error MISSING_REQ_ID
error MISSING_KEY
```#### Remove
Removes specified `key` from map.``` console
# If key doesn't exist or removed respond with :
remove
# or responds with one of the errors below :
error error MISSING_REQ_ID
error MISSING_KEY
````#### Get
Asks for the value of the `key````console
get
````imd-srv` responds as :
``` console
# If key exists it responds with :
success
# or responds with one of the errors below :
error error MISSING_REQ_ID
error MISSING_KEY
error NO_SUCH_A_KEY
```
#### Unknown command
```console
# If an unknown command is sent responds with :
error error INAPPROPRIATE_COMMAND
```#### Example
Start `imd-srv` first and then connect to it with `nc`.``` console
calynr@calynr-dev:~$ nc 127.0.0.1 9424
put 14552 os ubuntu-20.04
14552 success
put 14347 login_date 2022/08/20
14347 success
get 15685 os
15685 success ubuntu-20.04
get 87194 login_date
87194 success 2022/08/20
remove 75834 login_date
75834 success
get 71049 login_date
71049 error NO_SUCH_A_KEY
```