I was using a network library prepared with Winsock 2 before, but because of too many problems, I planned to switch to another library.
This is a library built with boost asio, I'm planning to use it for a MMORPG game network infrastructure https://github.com/mustafakemalgilor/libtcp_boost
It's using io_context with multiple threads.
When a is accepted, we start a session to do the processing (using a shared pointer). The session then starts continuous read and write operations.
What is the problem ?
When data arrives, it takes a long time in the io_service, it does not process it immediately. When data is transmited continuously, the it is processed immediately, but when the data transmission is reduced, there are delays (it looks as though the system puts processing on hold?).
This didn't happen before with Winsock2.
All code can be found here in this project: https://github.com/mustafakemalgilor/libtcp_boost
Question
Why is causing the delays when using Asio?
Note that there is no delay when transmitting from server to client, but quite a lot when the client transmits the data to the server.
More Information and For Example
For example, let's say that someone in the game transmits a message , when player walking or using some skills or writing from chat. When walking in the game, using skills, talking from chat in the game, etc. in many cases the client sends some packets to the server.
The task of the server, after parsing these packets, is to process them immediately, so process the data as it comes. Here is the point that I can't understand. Normally the socket should read any data and combine it and process it, but in boost asio the system dont do this directly.
I think it's not waiting while processing data, it's waiting to process data, boost asio may be keeping buffer data somewhere.
More example to understanding :
User move packet, hexadecimal op code : 0x06 User chat packet, hexadecimal op code : 0x10 Speed hack checking packet, hexadecimal op code : 0x41
When the player moving in the game, 0x06 opcode packet sending from client to the server.
Every 1 second client sending 0x41 speed hack control packet to the server.
When the player writes a message from the chat in the game, the client sends the packet with the opcode number 0x10 to the server, the server should immediately process and respond to this packet, but the server processes the packets that it received before and keeps this message packet, that is, the new packet with the opcode number 0x10, waiting somewhere for a very long time, my this is exactly my problem, i couldn't find where exactly boost asio is waiting/pausing these packages.
If anyone wants to see live what the problem is, I can open Anydesk link and show it.
If there is no solution, which library would you recommend for TCP server based MMORPG game?
If I can't find a solution and find a ready library, I will work morning and evening to make my own library.