Sign in to follow this  

SDL Net - TCP Socket problem

This topic is 4077 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

Hello! I am tring to send a big file over a tcp connection. So i have to split it in about 1200 byte packets. No problem so far. But when I try to recive the packets on the other side he gives me an error because the packets are not yet there. If i put a SDL_Delay(100) infront of the recv command it works fine. But i don't want this because I don'd want so sleep my program. How can I fix this? Jacky2k

Share this post


Link to post
Share on other sites
you can try using a SDL thread for the function that does the receiving. anyway, you'll need to put that function in sleep that calls itself untill the file is completly received (you'll have to figure out how to do this one, if packages received == total packages, for example).

Share this post


Link to post
Share on other sites
Why do you need to split it into packets? Just write the serialized file name, the length, and then that many bytes. TCP takes care of the streaming and fragmentation all by itself.

On the other side, if you don't want an EAGAIN when receiving, then use a blocking socket (so recv() will wait), or use select() to test for data.

Share this post


Link to post
Share on other sites

This topic is 4077 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