Update Seems like this issue is not as close related to Indy as I thought and more a topic on multi threading. I'll keep the question open as I am not 100% convinced.
I have a working application which is exchanging ascii strings with communication partners using Indy TCP client. The communication flow looks like this:
- [Indy Level] Sender sends string
- [TCP Level] Wireshark tells that this packet was delivered to the recipient
- [TCP Level] The recipient sends a TCP ACK to confirm this packet
- [Indy Level] The IOHandler.ReadLn method of recipient returns the data
- [Indy Level] Via writeLn() a logical Acknowledgement is sent to the original sender
Recently I noticed that there a hickups in that communication, after fiddeling with wireshark I got the following picture:
- [Indy Level] Sender sends string
- [TCP Level] Wireshark tells that this packet was delivered to the recipient
- [TCP Level] The recipient sends a TCP ACK to confirm this packet
- [Indy Level] The IOHandler.ReadLn method of recipient does not return any data
- Nothing to do as no data is available for recipient
After some timeout the sender send the orginal message again because there was no logical Acknowledgment from the recipient.
So my question is: If wireshark tells me that the underlying TCP mechanics did their work, how is it possible that the Indy Client has no data available?
Regards, Attix
ReadLn(), or 2) more likely, you have multiple threads reading from the same Indy IOHandler at the same time and are corrupting the content of the IOHandler.InputBuffer such thatReadLn()cannot find the line terminator correctly. DO NOT read from the same IOHandler in multiple threads at the same time. That includes callingConnected, which performs an internal read. - Remy Lebeau