Strange rare out-of-order data received using Indy

Posted by Jim on Stack Overflow See other posts from Stack Overflow or by Jim
Published on 2010-03-14T02:02:25Z Indexed on 2010/03/14 2:05 UTC
Read the original article Hit count: 475

Filed under:
|
|
|

We're having a bizarre problem with Indy10 where two large strings (a few hundred characters each) that we send out one after the other are appearing at the other end intertwined oddly. This happens extremely infrequently.

Each string is a complete XML message terminated with a LF and in general the READ process reads an entire XML message, returning when it sees the LF.

The call to actually send the message is protected by a critical section around the call to the IOHandler's writeln method and so it is not possible for two threads to send at the same time. (We're certain the critical section is implemented/working properly). This problem happens very rarely. The symptoms are odd...when we send string A followed by string B what we received at the other end (on the rare occasions where we have failure) is the trailing section of string A by itself (i.e., there's a LF at the end of it) followed by the leading section of string A and then the entire string B followed by a single LF. We've verified that the "timed out" property is not true after the partial read - we log that property after every read that returns content. Also, we know there are no embedded LF characters in the string, as we explicitly replace all non-alphanumeric characters in the string with spaces before appending the LF and sending it.

We have log mechanisms inside the critical sections on both the transmission and receiving ends and so we can see this behavior at the "wire".

We're completely baffled and wondering (although always the lowest possibility) whether there could be some low-level Indy issues that might cause this issue, e.g., buffers being sent in the wrong order....very hard to believe this could be the issue but we're grasping at straws.

Does anyone have any bright ideas?

© Stack Overflow or respective owner

Related posts about indy

Related posts about indy10