Advertisement

windows async sockets?

Started by February 05, 2006 03:20 PM
5 comments, last by DadleFish 19 years ago
i've been reading different websites for a few hours and everyone of them is giving different ways to go about this and none of them are working. all i want to do is recv() and if nothing is there to be received my program keeps working. the only thing that i think i've found thats on the right track is WSAEventSelect(). i looked up some information on WSAEventSelect() and it didn't really seem like thats what i want. so if anyone can tell me what functions i need i'd really appreciate it. and if you know of any examples or tutorials etc.. that would be great to. thank you for your time.
The classic way to do that is using a call to select() to check if there is something in the socket buffer that waits for you to recv() it. If not, carry on with your program "main loop" until you come back and check again. Sometimes you should do it in a different thread that just calls select() and then calls recv() and carries on with this loop until it is terminated.

WSAEventSelect is basically Microsoft's version for select, and I don't know of any particular advantage of using it over the portable select() alternative.

What you CAN use in WSA and it is basically the only thing worth using in WSA in my humble opinion is the WSAAsyncSelect, which can call your callback function for you when it has something "interesting" for you to handle.
Dubito, Cogito ergo sum.
Advertisement
i tried using select but it didn't work. when there wasn't anything to receive it was still selecting the sockets. is there something besides just setting the fd_set and checking if it isset to use it?
You can use ioctlsocket() to set the socket to non blocking mode.
i tried using ioctlselect() and that doesn't work either. it still tries to receive when there isn't anything to receive.
"It doesn't work" is an incorrect statement. They happen to work perfectly fine, you just have to implement them correctly. http://beej.us/guide/bgnet/output/html/selectman.html read, read, read. You will understand if you read and lookover the supplied code enough times.

EDIT: What do you mean it still tries to receive when there isn't anything to receive?
Hello?
Advertisement
I believe he means the recv call blocks when there is nothing to be received.

Yahn, if you want, upload your code fraction here and I'll see if I can find anything out of order. ioctlsocket and select work for me and they should for you too.
Dubito, Cogito ergo sum.

This topic is closed to new replies.

Advertisement