Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tcp/ip over Lan : ok Internet : Not ok : (

Status
Not open for further replies.

ChxNDmail

Programmer
Dec 15, 2001
14
US
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
 
Chip,

Thanks for that info. I will implement some
handshaking as well transmitting the rec'd length.
Much appreciated you reply.

Chx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top