README.md 2.9 KB
Newer Older
Y
youngwolf 已提交
1 2
st_asio_wrapper
===============
Y
youngwolf 已提交
3 4
Overview
-
5
st_asio_wrapper is an asynchronous c/s framework based on Boost.Asio, besides all benefits brought by Boost and Boost.Asio, it also contains: </br>
Y
youngwolf 已提交
6 7 8
1. Based on message just like UDP with several couple of build-in packer and unpacker;</br>
2. Support packer and unpacker customization, and replacing packer and unpacker at run-time;</br>
3. Automatically reconnect to the server after link broken;</br>
Y
youngowlf 已提交
9 10
4. Support object pool, object reusing and restoration;</br>
5. Worker thread management;</br>
Y
youngwolf 已提交
11
6. Support message buffer;</br>
Y
youngowlf 已提交
12
7. Widely support timers;</br>
Y
youngwolf 已提交
13 14 15
8. Support TCP/UDP and Unix domin TCP/UDP;</br>
9. Support reliable UDP (base on KCP -- https://github.com/skywind3000/kcp);</br>
10. Support ssl;</br>
16

Y
youngwolf 已提交
17 18
Quick start:
-
19
### server:
Y
youngwolf 已提交
20
Derive your own socket from `server_socket_base`, you must at least re-write `on_msg_handle` virtual function and handle messages in it;</br>
Y
youngowlf 已提交
21
Create a `service_pump` object, create a `server_base<your_socket>` object, call `service_pump::start_service`;</br>
Y
youngwolf 已提交
22
Call `server_socket_base::send_msg` or `server_base::broadcast_msg` when you have messages need to send.</br>
23 24
### client:
Derive your own socket from `client_socket_base`, you must at least re-write the `on_msg` or `on_msg_handle` virtual function and handle messages in it;</br>
Y
youngowlf 已提交
25
Create a `service_pump` object, create a `multi_client_base<your_socket>` object, add some socket via `multi_client_base::add_socket`, call `service_pump::start_service`;</br>
Y
youngwolf 已提交
26
Call `client_socket_base::send_msg` or `multi_client_base::broadcast_msg` when you have messages need to send.</br>
27

Y
youngwolf 已提交
28 29
Directory structure:
-
Y
youngwolf 已提交
30
All source codes are placed in directory `include`, other directories hold demos, for documents, please refer to this project  https://github.com/youngwolf-project/ascs/ .</br>
31

Y
youngwolf 已提交
32 33
Demos:
-
34 35 36 37 38 39 40
### echo_server:
Demonstrate how to implement tcp servers, it cantains two servers, one is the simplest server (normal server), which just send characters from keyboard to all clients (from `client` demo), and receive messages from all clients (from `client` demo), then display them; the other is echo server, which send every received message from `echo_client` demo back.</br>
### client:
Demonstrate how to implement tcp client, it simply send characters from keyboard to normal server in `echo_server`, and receive messages from normal server in `echo_server`, then display them.</br>
### echo_client:
Used to test `st_asio_wrapper`'s performance (whith `echo server`).</br>
### file_server:
Y
youngwolf 已提交
41
A file transfer server.</br>
42
### file_client:
Y
youngwolf 已提交
43
A file transfer client, use `get <file name1> [file name2] [...]` to fetch files from `file_server`.</br>
44
### udp_client:
Y
youngwolf 已提交
45
Demonstrate how to implement UDP communication.</br>
46
### ssl_test:
Y
youngwolf 已提交
47
Demonstrate how to implement TCP communication with ssl.</br>
48

Y
youngwolf 已提交
49
Compiler requirement:
Y
youngwolf 已提交
50
-
51 52
No special limitations, just need you to compile boost successfully.</br>

Y
youngwolf 已提交
53
Boost requirement:
Y
youngwolf 已提交
54
-
Y
youngwolf 已提交
55
1.49 or highter.</br>
56

Y
youngwolf 已提交
57
email: mail2tao@163.com
Y
youngwolf 已提交
58
-
Y
youngwolf 已提交
59
Community on QQ: 198941541
Y
youngwolf 已提交
60
-