Web Development

General discussion


socket programming with visual c++.net

By liloo_j ·
I have a lan network with a network card wich support more than 100mb and the hosts communicate through TCP sockets (the code is written in visual c++.net) but when the rate of packet send goes high, then some of packets are lost. my os is win XP . what should i do ?
is there any problem with os ? or sockets ?
why do the packets lost?(my sockets are Csocket)

Thanks for your generous help

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

by DSR28 In reply to socket programming with v ...

Interesting... TCP (Transmission Control Protocol) should not allow data to be lost on the network, unless you are not handling the inbound data properly, or are reading half the data. If it was UDP, delivery would not be guaranteed and this problem would most certainly arise, but if it is true TCP - if you send 80 MB, all 80 MB will arrive (the sender will slow to the speed of the receiver to guarantee the packets are delivered in order, and in a reliable manner), hence "Transmission Control Protocol"

I suspect the code/protocol that is doing the reading may be at fault. Use a network packet sniffer to verify the data is all being sent - and look over the reciever code. If the code uses CSocket, check around the receive calls to ensure nothing bad happens when receive returns 0 bytes (that doesn't normally mean end-of-data, unless an error is set too!). Perhaps even set the timeouts on a setsockopt call to ensure you are allowing proper time to sit and wait for the data.

Collapse -

by $dunk$ In reply to socket programming with v ...

This may be a little late in answering, but (as DRS28 said) TCP should be guaranteeing that packets are not lost. What I suspect is happening is that your receiving code is only reading part of the data and returning, which is expected and normal, especially when the system is busy. TCP does not guarantee that bytes arrive in the same packet/message as sent, it just guarantees the bytes arrive in order. You have to write the receiving code to continue reading until all the expected bytes for a particular message are received. ie. You need to keep track of how many bytes have been read and keep reading until you've read the expected number of bytes. You should also have an eventual timeout to keep your application from hanging forever.

Collapse -

by vijayykaushik In reply to socket programming with v ...

Hi dear , i am also working for same but in vc# and facing the same problem . Can you send me your code as i needed to convert my application in vc++, if u require i can send my code to you.

Related Discussions

Related Forums