Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/stackoverflowexcept1on/tcp-daemon-for-linux

TCP client-server application written in C++20 using Boost.Asio
https://github.com/stackoverflowexcept1on/tcp-daemon-for-linux

boost-asio cmake conan cpp20 linux

Last synced: 4 days ago
JSON representation

TCP client-server application written in C++20 using Boost.Asio

Awesome Lists containing this project

README

        

### TCP client & server (C++20 & Boost.Asio)

[![Build Status](https://github.com/StackOverflowExcept1on/tcp-daemon-for-linux/actions/workflows/ci.yml/badge.svg)](https://github.com/StackOverflowExcept1on/tcp-daemon-for-linux/actions/workflows/ci.yml)

[![asciicast](https://asciinema.org/a/zxX8zMCGW5bf8zSJtSe1Z4EI5.svg)](https://asciinema.org/a/zxX8zMCGW5bf8zSJtSe1Z4EI5)

This is one of the cool tasks from my university

### Task description

Implement a multi-threaded client-server application under Linux.

- Client is a program launched from the console
- The server is a daemon that gracefully terminates on `SIGTERM` and `SIGHUP` signals
- The client must transfer the contents of the text file via TCP
- The server must accept connection and save TCP stream to a file

### Requirements

- cmake
- conan

### Building

```bash
./build.sh
```

### Integration with CLion

By default, this may result in an error, to fix this:
1. execute `cd cmake-build-debug && conan install ..`
2. refresh CMake build

### Server

```bash
# run server at port 1234
./build/bin/server 1234

# check that daemon started
lsof -i :1234

# connect to server using netcat
echo "some data" | nc -N 0.0.0.0 1234

# read logs of the daemon
grep tcp_server_daemon /var/log/syslog

# clear syslog
sudo truncate -s 0 /var/log/syslog
```

### Client

```bash
# generate random file
head -c 1G large
sha256sum large

# send file to the server
./build/bin/client 127.0.0.1 1234 large
```