Sign in to follow this  
Vortez

Question about sending/recving large data block

Recommended Posts

Hi, here's the problem, some years ago, i develloped a client/server program to do a program very similar to vnc. Back then, i ran into a problem, when sending large amount of data in 2k chunk, i had to let the receiver notify the sender that it has received all the chunk, so the server would read that and write back another chunk. If i didn't did that, it seem i was loosing some data. Then i've read in the winsock faq that this is related to "the silly windows problem"(that's how they call it). Not only that seem to slow down the process a little, it also render both programs unable to read/write in separate threads(i can only do one at the time, in the same thread). This may be a little easier to debug, but not really efficient imo. So, does winsock really loose packets when the receiver is slower than the server and can't catch up?

Share this post


Link to post
Share on other sites
[quote] So, does winsock really loose packets when the receiver is slower than the server and can't catch up?[/quote]

A properly implemented TCP-based application should not lose data. send() returns number of bytes actually queued for sending, after the data should be considered sent. The only case where data would not be sent is some fatal flaw, such as application crash, but in that case it wouldn't really matter anymore or would require third-party management of transmitted data.

Share this post


Link to post
Share on other sites
Well, in the first version, i was sending data as fast as i can, and the client was crashing after a little while, by debugging it i saw that portions of the bitmap image was missing, and was making it crash. So after reading about the "silly windows syndrome" i descripted above, i syncronised the server and client by making the server wait for a small client packet that request more data, then it stopped crashing and everything was working fine, but now i think this is slowing the transfer rate a bit, and i can't use 2 separate thread for reading/writing.

My projects are setuped on 2 virtual machine on a virtual network, using the ip 192.168.0.1 and 192.168.0.2, so the transfer rate was very fast. Well i guess im gonna have to code another server/client apps to do some tests.

Here's an example of what's happening in my programs:
http://www.tcpipguide.com/free/t_TCPSillyWindowSyndromeandChangesTotheSlidingWindow.htm

Share this post


Link to post
Share on other sites
[quote name='Vortez' timestamp='1298309569' post='4777112']
i ran into a problem, when sending large amount of data in 2k chunk, i had to let the receiver notify the sender that it has received all the chunk, so the server would read that and write back another chunk. If i didn't did that, it seem i was loosing some data. Then i've read in the winsock faq that this is related to "the silly windows problem"(that's how they call it). Not only that seem to slow down the process a little, it also render both programs unable to read/write in separate threads
[/quote]

From your description, it sounds as if the problem is bugs in your program, not in TCP.
Example bugs may include not being prepared for packets being received in parts, and the common threading pitfalls having to do with mutexes and data structures.

Share this post


Link to post
Share on other sites

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