Advertisement Jump to content


This topic is now archived and is closed to further replies.


constantly sending and receiving

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

I'm using sdl_net and i've never done any network programming before. I was planning on doing a len=SDLNet_TCP_Recv(client,message,1024); at every opportunity and a Send at every opportunity too both as the client and the server. And i figure that if len = 0 in the Recv, that means that i'm trying to receive faster than the client has sent, so in that situation i just wait a bit and try again. Now, is there anything at all wrong with doing it this way? I'm a bit worried the "constantly trying to recv/send" can't work? Or is this in fact how everyone already does it? [edited by - tieTYT on May 30, 2004 7:01:27 AM]

Share this post

Link to post
Share on other sites
I don''t know how the SDL libraries handle it, but usually send and receive are blocking function, i.e they don''t return until all the data is sent or data is received, respectively. This is terrible, since your entire application comes to a screeching halt if there''s nothing to read, especially.

I''ve heard of using select with sockets, but never actually tried it. Usually I put all my network code in a separate thread and process it there. I don''t know if SDL has asynchronous networking either, but that is also a solution.

(P.S. just for reference, if receive returns 0 it means that the remote host disconnected, otherwise it would block waiting for data )

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!