I'm writting a local server in Node.js for a C# app. In my C# code i have something like that:
for(int i = 0; i < 1000; i++)
SendMessageToNodeOverTCP(i);
The messages are sent from a sep thread. The expected output in node should be: 0,1,2,3,4,5,6,7,8,...,998,999. But what I get is this: 0,3,5,6,9,10,15,20,...995,997,998,999.
I'm pretty sure the problem is in Node.js side, and I'm not sure if its really losing data, or if i did something wrong...
My JS code is the following:
function OnData(p_data){
LogData(p_data); //display the numbers in a custom gui
};
net.createServer(function (p_socket) {
p_socket.on('data', OnData);
}).listen(p_port);
I was able to solve my own problem...
After a bit of reasearch I found that in TCP sometimes they stack packages togheter. In node I was getting the data, passing it through a stream and creating a class from it. What i had to do, is check if there was data left in the stream, and process that too...
Thx folks!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.