I apologize in advance, but I'm quite pissed that not only do I have to deal with this same bug for nearly a year now, but the forums just ate my beautiful post explaining my entire problem in complete detail.
Long story short: I am misusing the TCPClient class. I am sending 400-500 byte messages, and data is being lost.
How can the TCPClient class be misused to lose data?
Random notes:
-I know the TCP protocol doesn't lose data. Don't tell me that. I am educated.
-I am buffering all data being received before checking for messages and reading them, so don't tell me this either. I have quite a spiffy message system tried and proven. It's just these large chunks of data screwing me over.
-I am using BeginRead/EndRead to receive my data.
-I am using a huge receive and send buffers, this simply can't be the problem unless I'm misusing them.
-Changing the receive buffer does affect how long before it breaks. However, how many bytes it takes before it breaks is inconsistent, even with the same bytes being sent each time.
-Through tedious byte by byte comparison, it appears that "older" bytes are being overwritten with newer, more recently received bytes. By comparing the sent and received bytes, there is a gap of missing bytes in the center. It's as if the buffer is too small, though, 3 megabytes for 500 bytes should be plenty of space... plus, the EndRead function should be called anyway!
-I have read that the ReceiveTimeOut property should be set to something else than zero to ensure no loss of data. Why is this? What if it ran out of time and no bytes were received? Wouldn't this return a length of zero bytes and appear to be a disconnection?
-Where it breaks is inconsistent. I can do the same login procedure time and time again, and it will break at different places.
-Kinda unrelated: What is the State argument for in the BeginRead function!? MSDN says you should "at the minimum pass the NetworkStream class." One example passes the TCPClient class. Another example passes seemingly random things (the form, a button on a toolstrip). The example I based mine off of passed nothing/null.
Thanks; I'm sorry for the ugliness of this post, but losing my well-written post was the last thing I needed right now.
Long story short: I am misusing the TCPClient class. I am sending 400-500 byte messages, and data is being lost.
How can the TCPClient class be misused to lose data?
Random notes:
-I know the TCP protocol doesn't lose data. Don't tell me that. I am educated.
-I am buffering all data being received before checking for messages and reading them, so don't tell me this either. I have quite a spiffy message system tried and proven. It's just these large chunks of data screwing me over.
-I am using BeginRead/EndRead to receive my data.
-I am using a huge receive and send buffers, this simply can't be the problem unless I'm misusing them.
-Changing the receive buffer does affect how long before it breaks. However, how many bytes it takes before it breaks is inconsistent, even with the same bytes being sent each time.
-Through tedious byte by byte comparison, it appears that "older" bytes are being overwritten with newer, more recently received bytes. By comparing the sent and received bytes, there is a gap of missing bytes in the center. It's as if the buffer is too small, though, 3 megabytes for 500 bytes should be plenty of space... plus, the EndRead function should be called anyway!
-I have read that the ReceiveTimeOut property should be set to something else than zero to ensure no loss of data. Why is this? What if it ran out of time and no bytes were received? Wouldn't this return a length of zero bytes and appear to be a disconnection?
-Where it breaks is inconsistent. I can do the same login procedure time and time again, and it will break at different places.
-Kinda unrelated: What is the State argument for in the BeginRead function!? MSDN says you should "at the minimum pass the NetworkStream class." One example passes the TCPClient class. Another example passes seemingly random things (the form, a button on a toolstrip). The example I based mine off of passed nothing/null.
Thanks; I'm sorry for the ugliness of this post, but losing my well-written post was the last thing I needed right now.
Last edited: