The problem in your case is that you use the wrong function to print the error. On Windows the socket functions doesn't set errno
, so the perror
function can't be used.
Instead you have to use WSAGetLastError
to get the error code. That is why your error message doesn't really make any sense.
You should probably use WSAGetLastError
in the other cases to. For example, bind
can fail because of other reasons too.