Answer the question
In order to leave comments, you need to log in
NodeJS How to make sockets blockable?
Good afternoon.
To communicate between the client and the server, I use the net. The client is written in C++ and uses regular system sockets.
I pass a lot of data to the client, in the form of portions. I noticed that the server does not wait for the moment when the client receives the data and immediately sends the next packet. Because of this, the client does not process the intended portion, but joins some portions together.
Before me was the question:
How to ensure that the server would wait for the moment - when the packet reaches the client, and only then send the next packet.
I read a little about the specifics of sockets, I learned that sockets can be blocking and not blocking. That is, at the native level, there is something like the TCP_NO_WAIT flag, which says that you do not need to wait for a response about data delivery, which is why it immediately sends the next portion without waiting.
So how do you make a socket blockable? So that he waits for a response about the delivery and only then sends the next package.
Answer the question
In order to leave comments, you need to log in
> Because of this, the client does not process the intended portion, but joins some portions together.
You have a problem on the client. A socket is a pipe into which bytes are pushed in on one side and pushed out on the other. If your client is unable to distinguish between 2 packets in the byte stream, then it is a bad client.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question