Jump to content
  • Advertisement

Archived

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

hello_there

network question

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

when you call listen() does it keep listening even if you don't call it again? for example i should only call it at the start of my game and not call it every frame? also should i call accept() every frame. and what does accept() return if there's no user wait to be accepted. [edited by - hello_there on January 18, 2003 10:29:41 PM]

Share this post


Link to post
Share on other sites
Advertisement
You call listen() only once, usually right after you''ve created your listen socket. Call it at the start of your game, not every frame.

The accept() function will block (not return) until it accepts a new connection (or encounters an error) unless it is called on a non-blocking socket. This can be a serious problem, since you probably want to be doing other things in your game, not waiting around for somebody to connect.

How often you call accept() is up to you, but once per frame would probably be sufficient.

Share this post


Link to post
Share on other sites
say i want to keep checking if someone is trying to connect and accept them if there is and still play the game what would i do? call it once per frame or put it on non-block or what ever.

Share this post


Link to post
Share on other sites
among the alternatives:
put it in a separate thread, or
use wsaasyncselect, or
use a nonblocking socket and poll it with select or wsaeventselect every now and then, or
use acceptex

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!