- Thread-Safety Design
- using
mutex
protect the connectionrecv buffer
andsend buffer
- using
mutex
protect thefd to connection map
- using
atomic_bool
preventclose(fd)
multiple times
- using
- Fair Usage Policy
- set quota for send counters per connection
- quota : 10
- set the maximum number of bytes sent by each sending process
- max sending bytes : 1500
- set quota for send counters per connection
- Detect Undetectable Disconnections (e.g.: power outage / vpn disconnection)
- detect unsendable connection with non-blocking mode when sending
- leave it for 5 seconds, if it go back to sendable state, then keep send
- if connection still unsendable state after 5 seconds, then close it
This is a header-only library.
Clone this repo and copy include/*
to /usr/local/include/
.
# clone this repo
git clone https://github.com/KingsFourze/SafetyTcpConn.git
# copy library to include folder
cd SafetyTcpConn
sudo cp include/* /usr/local/include/ -r
Or you can include by using CMakeLists.txt by:
include_directories([path_to_library])
See demo/main.cpp
- Ubuntu 22.04 LTS (WSL)
- GCC Version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04)
- GDB Version 12.1 (Ubuntu 12.1-0ubuntu1~22.04)
- CPython 3.12.2