Sign in to follow this  

Sending data too fast?

This topic is 3301 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

sockMain.SendData "T" sockMain.SendData HP.Caption When I use winsock to send data continuously, the data receive will be combined. How to solve this problem??? Is I need to delay the message? If it does, how to implement it? Thank YOU

Share this post


Link to post
Share on other sites
I know what is TCP/IP
I suppose the reason of my case is the 2 packets delivered within a short period time and then they are being assembled.
However, how to solve it ,thx

Share this post


Link to post
Share on other sites
Quote:
Original post by tonald
I know what is TCP/IP
I suppose the reason of my case is the 2 packets delivered within a short period time and then they are being assembled.
However, how to solve it ,thx
No - you're not sending two packets. TCP doesn't have any concept of packets, it's stream based. The data you sent could be read in 20 recv() calls if the API feels like it.

If you want to deal with "packets" with TCP, you'll need to prefix every message with it's length in bytes. Then you just need to read the length of the packet, and then that many bytes. See Question 14 in the Forum FAQ: Q14) I'm trying to send two packets over TCP, but it seems like they arrive "merged" or one packet disappears on the receiving end. What's going on?

Share this post


Link to post
Share on other sites
however, when I send the packetA , wait for a moment , then send the packet B
They do not being combined.....
Is it mean that only 2 continusous packets appear this problem??
By the way,this problem is because the receiver do not know the end of the stream, right?

Share this post


Link to post
Share on other sites
Quote:
Original post by tonald
however, when I send the packetA , wait for a moment , then send the packet B
They do not being combined.....
Is it mean that only 2 continusous packets appear this problem??
By the way,this problem is because the receiver do not know the end of the stream, right?
No, you're not sending packets. TCP doesn't send packets, it sends a stream of data. If you make two send() calls in quick succession, then by the time the receiving end processes the stream, both buffers are available.

Read Q14 of the forum FAQ.

Share this post


Link to post
Share on other sites
That's probably because while you wait between A and B the receiver read A and consider it as what you call a packet then you send B and it can read B as a new "Packet"

Share this post


Link to post
Share on other sites
I understand now. Thank you all of you
But, the school textbox tells me that tcp divide the message into packets and send it,IP route the packets and last combine all packets at the destination

Share this post


Link to post
Share on other sites

This topic is 3301 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this