I am using IOCP in my client, but I find it more convenient to use a blocking call when connecting to the server. So is there any problem in using the blocking WSAConnect()
instead of the non-blocking ConnectEx()
when working with IOCP?
Yes, it's perfectly fine.
a call to WSAConnect
will block the thread until a connection has being created/ an error has occured. then, you can do asynchronous IO and get notification about completed packets with your application IOCP. the IOCP will not give any packets regarding WSAConnect
.
Another point is that IOCP works exculsivly with Overlapped IO. if your function does not consume any memory location of OVERLAPPED
struct (like WSAConnect
), you can be sure that IOCP will not deal with that API call. even if OVERLAPPED
supplied, that doesn't mean that the action is asynchronous and will be published in the IOCP.
you might want to take a look at Boost.Asio
for C++ and libuv
for C. the code then will be portable as well (and less buggish). another intresting platform is microsoft Casablanca
, which is cross platform, but in my experince the performance is catastrophic.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With