Jump to content
  • Advertisement


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


Non-blocking Accept

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

Im reading Multiplayer Game Programming to kind of wade into network programming. I also have Windows Socket Network Programming. I need to use sockets (not DirectPlay). The game Im making is turn based, so its not very network intensive at all. Im using this game sort of as a steping stone to get a better idea for network programming. So I decided to use the SocketObject that the author provides in MPGP. SOOO.. what Im looking at is the Accept function. Its a blocking call, so the program hangs while waiting for a client to join. Im looking for a way around this, or at least a way the user can press Esc to cancel or something. I''ll probably have to use threads. I looked at the SocketObject''s vGetPacket method for an example, but cant really come up with a way to make a similiar method with Accept. If someone can help me out I''d be very greatfull. Everything else in the game works fine using the SocketObject, its I cant have the Accept function being a blcoking call. Thanks Ratman --------------- Ratfest.org

Share this post

Link to post
Share on other sites
Well, I don''t know about the internals of the SocketObject class ... but you can turn a normal socket into a non-blocking socket like so:
fcntl(socketDescriptor, F_SETFL, O_NONBLOCK);

You could also use asynchronous sockets with select(), but I''m not too familiar with that


Share this post

Link to post
Share on other sites
Guest Anonymous Poster
If your going to use non-blocking sockets under winsock you have 2 choices. You can use the BSD non-blocking sockets, where you use select to poll the state of the socket, and handle the events when they occure, or you can use the windows specific asynchronus sockets, where you hook sockets up to the windows event loop, and handle the socket events within the winproc.

Look on this website for more info.


Good Luck


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!