🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

socket accpet hangs

Started by
4 comments, last by siliconsmiley 22 years, 10 months ago
I''m trying to build the SocketObject from Todd Barron''s Multiplayer Game Programming book, chapter 5. The CD that came with the book has, of course, been lost in the sands of time. I''ve gotten upto pages 182-183, the code is written and it looks right. When I call ServerSocketObject.Accept(ClientSocketObject) it hangs at the call to accept. Any suggestions?
Advertisement
Just a guess because I don''t have the book, but it sounds like it''s not hanging, but blocking. I''m guessing the socket is operating in blocking mode and it''s waiting for a client to try and connect.
Hi.. i dont have the book but it sounds like your using a "blocking" socket..

there are 2 ways (well 3 ways in Windows 2000 +) to implement sockets ..

Blocking - everything they do blocks execution on the thread untill it compleats (Accept calls, Write, Read etc)

Non-Blocking - This is the Async way.. basically windows sends a message to your app when the opperation is complete

Pros n Cons (note there was another thread on this blocking or non-blocking) :

non-blocking.. easy because you can have all sockets on 1 thread but windows Does limit the number of sockets you can reliably have on a single thread (64 i believe)

Blocking.. You will need a seperate thread for each socket so when they block the other threads continue ;-) the prob here is when you have 100''s of threads running windows starts to get less responcive because its haveing to switch between so many thread :-/

the best (windows 2000 + only) solution then is IO Completion ports which again has discussed before recently ;-)

hope thats helped and im not just rambling (as always)

~tim
~ Tim
Just one little correction Wrathgame.

I/O completion ports have been available since Windows NT 3.51



Dire Wolf
www.digitalfiends.com
[email=direwolf@digitalfiends.com]Dire Wolf[/email]
www.digitalfiends.com
Thanks for the posts folks. This seems like a pretty active forum. I''m going to try to build a plug in for Asheron''s Call. I want to build a bot that will translate commands that I enter into the chat window into mouse movents and other commands. Anybody know of a good developer site for Decal?
I know this thread is old, but something does need correction.

Even if you''re using blocking sockets, you won''t need one thread per socket. That''s exactly what select() and poll() are for. Of course, techniques like I/O completion ports and RT signals scale better to huge connection counts, as we''ve discussed in detail in a different thread
If you can''t use any of those techniques tho (i.e. on Win9x, non-patched Linux, ...), using select() is probably a lot more efficient than using threads in most cases.

cu,
Prefect

One line of sourcecode says more than a thousand words.
Widelands - laid back, free software strategy

This topic is closed to new replies.

Advertisement