Winsock Non-blocking Problem

Hi all,

Im not sure exactly how non blocking programming works ( how it exactly works and runs ).

I am trying to get a client to send a server a data packet and it doesnt get there for some reason, I call send once and it works, but the second and third time it does not.

Ive seen the function 'select' around on many forums and im not sure of its usage ( something to do with checking the socket if its 'ready' )

If i could get a general outline or 'pseudocode' on how to use the 'select' function along with other winsock functions, thanks.

Note: Looking at my code, this may help,
I see that i am using send 3 times in succession, Does the server on the other end, buffer the data or are the last 2 calls lost?
Last edited on
Don't use that WSAAsync stuff for non-blocking comms on Windows.
1. it's a headache to learn
2. it doesn't do async properly
3. the knowledge is non-transerable
4. Microsoft may one day realise it's nonsense and drop support for it

What you really need to understand is I/O Completion ports.
http://msdn.microsoft.com/en-gb/library/windows/desktop/aa365198%28v=vs.85%29.aspx
http://www.drdobbs.com/cpp/multithreaded-asynchronous-io-io-comple/201202921

If you want a clean portable way of using them, use Boost ASIO.
http://www.boost.org/doc/libs/1_55_0/doc/html/boost_asio.html


If i could get a general outline or 'pseudocode' on how to use the 'select' function along with other winsock functions, thanks.
You start an operation and use select to check if it's done. There's an example here.
http://www.cplusplus.com/forum/unices/134736/#msg719809
Last edited on
Wow thanks! Much reading to do :)

And also thanks for clearing up the select function, wasnt sure how to use it

( For anyone else who reads this... )
I also found it to be a parsing error, as when i did two send calls side by side, the 'buffer' received both and thus puts the two received strings next to each other. This means that i cant just parse a single message.
Registered users can post here. Sign in or register to post.