🎉 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!
I need a non-blocking socket tutorial.
Does anyone know where I can find a non-blocking socket tutorial? I have looked around and I can only find blocking and asychronous. I have to use non-blocking because my program is a console app, so asychronous won''t work with it.
You could try to look at the "select" function. Or use multithreading (that''s what I did at first, but I''m trying to figure out how to implement select in my program).
"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said
![Resist Windows XP''s Invasive Production Activation Technology!](http://druidgames.warfactory.com/Out_Source/resist.jpg)
http://druidgames.cjb.net/
"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said
![Resist Windows XP''s Invasive Production Activation Technology!](http://druidgames.warfactory.com/Out_Source/resist.jpg)
http://druidgames.cjb.net/
select is async...and multithreading might be an unessesary step. Check out fcntl(). And also, there is no reason at all why you cant use async in a console app. While windows apps use WSAAsyncSelect(), a console app can implement the BSD select() call just like in a *nix app.
Here''s a function you can use to toggle a SOCKET between blocking and non-blocking mode.
// CHRIS
//// Set Socket Blocking Mode// sock = SOCKET Handle// mode = 0 for BLOCKING, 1 for NON-BLOCKING//BOOL SetSocketBlockingMode(SOCKET sock, int mode){ unsigned long lmode = mode; if(ioctlsocket(sock, FIONBIO, &lmode) == SOCKET_ERROR) return(FALSE); return(TRUE);}
// CHRIS
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement