Open CDixon0416 opened 2 years ago
You can not connect to the any address on Windows (but happens to work and connects to localhost in Linux). Are you suggesting that this should throw an exception on Windows?
You can not connect to the any address on Windows (but happens to work and connects to localhost in Linux). Are you suggesting that this should throw an exception on Windows?
I think it makes sense, currently there is no indication that something is wrong with the socket it will still attempt to receive without throwing a "socket operation on non-socket error" which I would expect since the connection is invalid.
Or perhaps there needs to be clarification in the documentation somewhere since there is no indication this is not allowed. (At least that I could find)
I think it's an easy enough mistake to make to blindly trust the get(last_endpoint) is going to provide a valid address and be confused as to why it doesn't work under windows.
During a port of a project from Centos 7 to Windows 10, I discovered some inconsistent behavior when connecting to a socket using a wildcard address and port. In the client code I manually connected to the port provided by the server code using 0.0.0.0 and no communication occurs, change the string to using localhost and the sockets communicate as expected.
This seems to be a problem that was already seen in libzmq https://github.com/zeromq/libzmq/pull/1920 and persists in cppzmq or at least in version 4.7.1 provided by vcpkg. While its not a huge problem it does mean windows code is required to parse out the port from socket.get(zmq::sockopt::last_endpoint) and change the connection string to use localhost or 127.0.0.1 with out any indicator of what the problem is.
Modified Client and Server code to replicate behavior: