Skip to content

Commit e8132a2

Browse files
Update README.md
1 parent 7a94f4b commit e8132a2

File tree

1 file changed

+74
-17
lines changed

1 file changed

+74
-17
lines changed

README.md

Lines changed: 74 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# [![LinuxBuildWorkflow](https://github.com/alejandrofsevilla/boost-tcp-server-client/actions/workflows/LinuxBuild.yml/badge.svg)](https://github.com/alejandrofsevilla/boost-tcp-server-client/actions/workflows/LinuxBuild.yml?event=push) [![TestsWorkflow](https://github.com/alejandrofsevilla/boost-tcp-server-client/actions/workflows/LinuxBuildAndTest.yml/badge.svg)](https://github.com/alejandrofsevilla/boost-tcp-server-client/actions/workflows/LinuxBuildAndTest.yml?event=push)
22
# Boost TCP Server/Client
33
Asynchronous [Boost.Asio](https://www.boost.org/doc/libs/1_74_0/doc/html/boost_asio.html) TCP server and client example.
4-
54
## Requirements
65
- C++17 compiler
76
- CMake 3.22.0
@@ -11,10 +10,6 @@ Asynchronous [Boost.Asio](https://www.boost.org/doc/libs/1_74_0/doc/html/boost_a
1110
## Usage
1211
### Server
1312
```cpp
14-
#include <TcpServer.hpp>
15-
#include <iostream>
16-
#include <thread>
17-
1813
struct : TcpServer::Observer {
1914
void onConnectionAccepted(int id) {
2015
std::cout << "New client connected with id " << id << std::endl;
@@ -43,10 +38,6 @@ server.startAcceptingConnections();
4338
```
4439
### Client
4540
```cpp
46-
#include <TcpClient.hpp>
47-
#include <iostream>
48-
#include <thread>
49-
5041
struct : TcpClient::Observer {
5142
void onConnected() { std::cout << "Client was connected" << std::endl; };
5243
void onReceived(const char* data, size_t size) {
@@ -67,20 +58,13 @@ TcpClient client{context, observer};
6758
constexpr uint16_t port{1234};
6859
auto address{boost::asio::ip::address::from_string("127.0.0.1")};
6960
client.connect({address, port});
70-
7161
```
72-
## How to build
62+
## Build
7363
- Install dependencies.
74-
- linux
7564
```terminal
7665
sudo apt-get install libboost-dev
7766
sudo apt-get install libgtest-dev
7867
```
79-
- macOs
80-
```terminal
81-
brew install boost
82-
brew install googletest
83-
```
8468
- Clone repository.
8569
```terminal
8670
git clone https://github.com/alejandrofsevilla/boost-tcp-server-client.git
@@ -95,3 +79,76 @@ client.connect({address, port});
9579
```terminal
9680
./build/tests/boost-tcp-server-client-tests
9781
```
82+
## Implementation
83+
84+
```mermaid
85+
classDiagram
86+
class C_0008186492458287629887["TcpConnection"]
87+
class C_0008186492458287629887 {
88+
+close() : void
89+
-doRead() : void
90+
-doWrite() : void
91+
+send(const char * data, size_t size) : void
92+
+startReading() : void
93+
-m_id : int
94+
-m_isReading : bool
95+
-m_isWritting : bool
96+
-m_readBuffer : boost::asio::streambuf
97+
-m_socket : boost::asio::ip::tcp::socket
98+
-m_writeBuffer : boost::asio::streambuf
99+
-m_writeBufferMutex : std::mutex
100+
}
101+
class C_0009297713916002777393["TcpConnection::Observer"]
102+
class C_0009297713916002777393 {
103+
+onConnectionClosed(int connectionId) : void
104+
+onReceived(int connectionId, const char * data, size_t size) : void
105+
}
106+
class C_0015464091438354772672["TcpClient"]
107+
class C_0015464091438354772672 {
108+
+connect(const boost::asio::ip::tcp::endpoint & endpoint) : void
109+
+disconnect() : void
110+
-onConnectionClosed(int connectionId) : void
111+
-onReceived(int connectionId, const char * data, size_t size) : void
112+
+send(const char * data, size_t size) : void
113+
-m_ioContext : boost::asio::io_context &
114+
}
115+
class C_0013920056604237995185["TcpClient::Observer"]
116+
class C_0013920056604237995185 {
117+
+onConnected() : void
118+
+onDisconnected() : void
119+
+onReceived(const char * data, size_t size) : void
120+
}
121+
class C_0002490684498279635516["TcpServer"]
122+
class C_0002490684498279635516 {
123+
+close() : void
124+
-doAccept() : void
125+
+listen(const boost::asio::ip::tcp & protocol, uint16_t port) : bool
126+
-onConnectionClosed(int connectionId) : void
127+
-onReceived(int connectionId, const char * data, size_t size) : void
128+
+send(int connectionId, const char * data, size_t size) : void
129+
+startAcceptingConnections() : void
130+
-m_acceptor : boost::asio::ip::tcp::acceptor
131+
-m_connectionCount : int
132+
-m_isAccepting : bool
133+
-m_isClosing : bool
134+
}
135+
class C_0004458731545202809661["TcpServer::Observer"]
136+
class C_0004458731545202809661 {
137+
+onConnectionAccepted(int connectionId) : void
138+
+onConnectionClosed(int connectionId) : void
139+
+onReceived(int connectionId, const char * data, size_t size) : void
140+
}
141+
C_0008186492458287629887 --> C_0009297713916002777393 : -m_observer
142+
C_0008186492458287629887 ()-- C_0009297713916002777393 :
143+
C_0015464091438354772672 --> C_0008186492458287629887 : -m_connection
144+
C_0015464091438354772672 --> C_0013920056604237995185 : -m_observer
145+
C_0015464091438354772672 ()-- C_0013920056604237995185 :
146+
C_0002490684498279635516 o-- C_0008186492458287629887 : -m_connections
147+
C_0002490684498279635516 --> C_0004458731545202809661 : -m_observer
148+
C_0002490684498279635516 ()-- C_0004458731545202809661 :
149+
C_0009297713916002777393 <|-- C_0015464091438354772672 :
150+
C_0009297713916002777393 <|-- C_0002490684498279635516 :
151+
152+
%% Generated with clang-uml, version 0.6.0
153+
%% LLVM version Ubuntu clang version 15.0.
154+
```

0 commit comments

Comments
 (0)