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

Non blocking sockets

Started by
1 comment, last by InfestedFurby 23 years, 5 months ago
Is there any basic tutorial out there on using non-blocking sockets w/ winsock? any help would be much appriciated. Infested Furby infestedfurby.cjb.net infestedfurby@hotmail.com
Infested Furbyinfestedfurby@hotmail.cominfestedfurby.cjb.net
Advertisement
I never found a tutorial online, but I am sure there is one. Also, the help file explains how to have nonblocking sockets too. Basically, what you have to do is set up a nonblocking socket by passing a parameter when creating your socket (I think) and then check if data is coming in using the select() function. Before you call select() you have to fill fd_struct which tells how often to check for data, this is the problem I had when I tried to set up nonblocking sockets. It appeared as if you have to fill the fd_struct every time you loop (I had an infinite loop). If select() returns an integer greater than 0 it means that data came in, and you would call recv(). Hope this helps.

-B4
If you call ictlsocket() with the FIONBIO command, it will be explicityly nonblocking.
Example:

unsigned long TheArgument = 1L;
int RetVal;
SOCKET TheSocket;

RetVal = ioctlsocket(TheSocket,FIONBIO,(unsigned long*)&TheArgument);


You can find some excellent tutorials on this and many other parts of winsock in the book "Windows Sockets Network Programming" (ISBN:0-201-63372-8).

Enjoy

This topic is closed to new replies.

Advertisement