Ultra fast and low latency asynchronous socket server & client C++ library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and 10K connections prob
Ultra fast and low latency asynchronous socket server & client C++ library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and 10K connections prob
Has integration with high-level message protocol based on Fast Binary Encoding
Optional:
sudo apt-get install -y binutils-dev uuid-dev libssl-devpip3 install gilgit clone https://github.com/chronoxor/CppServer.git
cd CppServer
gil updatecd build
./unix.shcd build
./unix.shcd build
unix.batcd build
mingw.batcd build
vs.batAsio service is used to host all clients/servers based on Asio C++ library. It is implemented based on Asio C++ Library and use a separate thread to perform all asynchronous IO operations and communications.
The common usecase is to instantiate one Asio service, start the service and attach TCP/UDP/WebSocket servers or/and clients to it. One Asio service can handle several servers and clients asynchronously at the same time in one I/O thread. If you want to scale your servers or clients it is possible to create and use more than one Asio services to handle your servers/clients in balance.
Also it is possible to dispatch or post your custom handler into I/O thread. Dispatch will execute the handler immediately if the current thread is I/O one. Otherwise the handler will be enqueued to the I/O queue. In opposite the post method will always enqueue the handler into the I/O queue.
Here comes an example of using custom Asio service with dispatch/post methods:
…Output of the above example is the following:
Asio service started!
1 - Dispatch from the main thread with Id 16744
2 - Post from the main thread with Id 16744
1.1 - Dispatched in thread with Id 19920
1.2 - Dispatch from thread with Id 19920
1.2.1 - Dispatched in thread with Id 19920
1.3 - Post from thread with Id 19920
2.1 - Posted in thread with Id 19920
2.2 - Dispatch from thread with Id 19920
2.2.1 - Dispatched in thread with Id 19920
2.3 - Post from thread with Id 19920
1.3.1 - Posted in thread with Id 19920
2.3.1 - Posted in thread with Id 19920
Asio service stopped!Here comes the example of Asio timer. It can be used to wait for some action in future with providing absolute time or relative time span. Asio timer can be used in synchronous or asynchronous modes.
…Output of the above example is the following:
Asio service starting...Done!
Timer was expired
Timer was canceled
Asio service stopping...Done!Here comes the example of the TCP chat server. It handles multiple TCP client sessions and multicast received message from any session to all ones. Also it is possible to send admin message directly from the server.
…Here comes the example of the TCP chat client. It connects to the TCP chat server and allows to send message to it and receive new messages.
…Here comes the example of the SSL chat server. It handles multiple SSL client sessions and multicast received message from any session to all ones. Also it is possible to send admin message directly from the server.
This example is very similar to the TCP one except the code that prepares SSL context and handshake handler.
…Here comes the example of the SSL chat client. It connects to the SSL chat server and allows to send message to it and receive new messages.
This example is very similar to the TCP one except the code that prepares SSL context and handshake handler.
…Here comes the example of the UDP echo server. It receives a datagram mesage from any UDP client and resend it back without any changes.
…Here comes the example of the UDP echo client. It sends user datagram message to UDP server and listen for response.
…Here comes the example of the UDP multicast server. It use multicast IP address to multicast datagram messages to all client that joined corresponding UDP multicast group.
…Here comes the example of the UDP multicast client. It use multicast IP address and joins UDP multicast group in order to receive multicasted datagram messages from UDP server.
…Simple protocol is defined in simple.fbe file:
…Here comes the example of the simple protocol server. It process client requests, answer with corresponding responses and send server notifications back to clients.
…Here comes the example of the simple protocol client. It connects to the simple protocol server and allows to send requests to it and receive corresponding responses.
…Here comes the example of the HTTP cache server. It allows to manipulate cache data with HTTP methods (GET, POST, PUT and DELETE).
Use the following link to open Swagger OpenAPI iterative documentation: http://localhost:8080/api/index.html
…Here comes the example of the HTTP client. It allows to send HTTP requests (GET, POST, PUT and DELETE) and receive HTTP responses.
…Here comes the example of the HTTPS cache server. It allows to manipulate cache data with HTTP methods (GET, POST, PUT and DELETE) with secured transport protocol.
Use the following link to open Swagger OpenAPI iterative documentation: https://localhost:8443/api/index.html
…Here comes the example of the HTTPS client. It allows to send HTTP requests (GET, POST, PUT and DELETE) and receive HTTP responses with secured transport protocol.
…Here comes the example of the WebSocket chat server. It handles multiple WebSocket client sessions and multicast received message from any session to all ones. Also it is possible to send admin message directly from the server.
Use the following link to open WebSocket chat server example: http://localhost:8080/chat/index.html
…Here comes the example of the WebSocket chat client. It connects to the WebSocket chat server and allows to send message to it and receive new messages.
…Here comes the example of the WebSocket secure chat server. It handles multiple WebSocket secure client sessions and multicast received message from any session to all ones. Also it is possible to send admin message directly from the server.
This example is very similar to the WebSocket one except the code that prepares WebSocket secure context and handshake handler.
Use the following link to open WebSocket secure chat server example: https://localhost:8443/chat/index.html
…Here comes the example of the WebSocket secure chat client. It connects to the WebSocket secure chat server and allows to send message to it and receive new messages.
This example is very similar to the WebSocket one except the code that prepares WebSocket secure context and handshake handler.
…Here comes several communication scenarios with timing measurement
No open issues yet, or sync has not completed.