elhayra / tcp_server_client

A thin and simple C++ TCP client server
MIT License
155 stars 53 forks source link

Fix bug when the previous data sent was larger #17

Open mellado opened 2 years ago

mellado commented 2 years ago

There is a bug when you send some data, and then in a second communication with smaller data you can see at the end of the the previous last part of the larger data. Then the size obtained is the same in both cases.

guitronimo commented 1 month ago

This same problem still exists when using option 1 or 3 from Server to client.

This seem to have fixed it:

client_example:


// observer callback. will be called for every new message received by the server
void onIncomingMsg(const char * msg, size_t size) {
    std::cout << "Got msg from server: " << std::string(msg, size) << "\n";
}```