Archived

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

hello_there

network question

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
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
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