TCP does not send / receive some data

Hello,
I am writing to the server and the client, but during testing I found an unpleasant thing, such that at some point I get stuck in communication between the client and the server. Sometimes it happens right after the first pair of messages, sometimes later. No error is thrown anywhere, only the server sends the message and does not reach the client.
Unfinished codes:
server: https://gist.github.com/matejstrnad/a25247788c1d5cb9f34a9fc3485ac120
client:
https://gist.github.com/matejstrnad/cc27f76fd69b929665a7a6542f2c8682
Sometimes this happens with a message on line 113 at the server, and 57 at the client; sometimes also for the message “ok” after sending the public key that arrives at the server, that is on line 59 at the server and 64 at the client.
How can I fix it and where is the error?
I also apologize for my English, I’m just learning it :slight_smile:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.