My tcpserver and tcpclient applications are working well
over the LAN but, over the INTERNET, long messages / files
get truncated. Can anybody tell me what is causing this ?
Thanks in advance.
The common error people make is misunderstanding the nature of TCP/IP. It's a stream-based protocol, not a record-based one.
You need to make sure that if you're the sender that you track how many bytes were actually sent, vs. how many you requested to be sent (you need to call Send again for the bytes that didn't go the first time).
If you're the recipient, you need to track how many bytes were actually received, and if you didn't get a complete record, you need to call Receive again. Note that you might get more bytes than make up a record -- you'll have to hold onto those until the next time your application needs to do a receive.
If you have variable-length records, you need to send the length of each record first (before the payload part). That way the recipient can know how big the record is, and know when they've received the correct number of bytes.
Chip H.
____________________________________________________________________ If you want to get the best response to a question, please read FAQ222-2244 first
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.