Missed Socket Message

I have been doing socket programming for many years, but so far I have never had a missed message using TCP. I have a Java server and client in C - both on the local host. They send short messages back and forth as strings, with some delays between them. I have one special case when a message never appears on the client side. This is reproducible, but strangely dependent on the machine.

To give more detailed information, I can debug the server side and see the dispatch followed by a flash. I can connect to the client and go through the selected calls (in a loop), but it just doesn't appear. Has anyone experienced this and there is an explanation other than a coding error?

In other words, if you have a connected socket and write on one side and read on the other, what could happen in the middle to cause something like this?

Another detail - I used tcpdump in the loopback interface and see a missed message.

+4
source share
2 answers

Finally - after I sniffed a little more, I found a problem. Two messages were sent before reading (sometimes, but rarely ...), so they were both read, but only the first ones were processed. That is why it seemed that the second message did not appear. He was buried in the reception buffer.

+1
source

I have seen this in SMTP transactions before. Do you have antivirus installed on your computer? If so, try disabling it and see if this has changed.

Otherwise, I would suggest installing Wireshark so you can see what is actually happening.

+4
source

Source: https://habr.com/ru/post/1286393/


All Articles