1
Network / Re: Nonblocking Tcp Socket Status is Never sf::Socket::Done
« on: August 21, 2021, 06:53:10 pm »
I experimented with this again, and I didn't find anything new. I decided to simply interpret NotReady as a successful return code primarily because:
SocketImpl::getErrorStatus maps Status::NotReady to WSAEWOULDBLOCK and WSAEALREADY.
According to windows-sockets-error-codes:
I'm going to take a break on this. When I look into this again, the next thing I'll look into is the FD_CONNECT notification. The document points me to use the select function:
https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-select
I recall that SFML already implements a SocketSelector. Admittedly I haven't researched the SocketSelector extensively. Perhaps I've been using nonblocking sockets incorrectly, and I was suppose to use the socket selector this whole time. It's something I'll look into.
SocketImpl::getErrorStatus maps Status::NotReady to WSAEWOULDBLOCK and WSAEALREADY.
According to windows-sockets-error-codes:
WSAEALREADY
A nonblocking connect call is in progress on the specified socket.
This is fine. I can work around this particular code by checking if I already sent a request or not.A nonblocking connect call is in progress on the specified socket.
WSAEWOULDBLOCK
It is normal for WSAEWOULDBLOCK to be reported as the result from calling connect on a nonblocking SOCK_STREAM socket, since some time must elapse for the connection to be established.
Seeing that it is normal for Windows to report that error code for nonblocking sockets, I think it would be fine to treat a normal code as a success especially since I never seen it return anything else in a successful case.It is normal for WSAEWOULDBLOCK to be reported as the result from calling connect on a nonblocking SOCK_STREAM socket, since some time must elapse for the connection to be established.
I'm going to take a break on this. When I look into this again, the next thing I'll look into is the FD_CONNECT notification. The document points me to use the select function:
https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-select
I recall that SFML already implements a SocketSelector. Admittedly I haven't researched the SocketSelector extensively. Perhaps I've been using nonblocking sockets incorrectly, and I was suppose to use the socket selector this whole time. It's something I'll look into.