I dont understand whats happening. If I create a socket to anywhere else other than localhost (either \"localhost\", \"127.0.0.1\" or the external ip of the machine) it works fi
You are not guaranteed to get a WSAETIMEDOUT
error when connecting to a non-listening port on another machine. Any number of different errors can occur. However, a WSAETIMEDOUT
error typically only occurs if the socket cannot reach the target machine on the network before connect()
times out. If it can reach the target machine, a WSAECONNREFUSED
error means the target machine is acknowledging the connect()
request and is replying back saying the requested port is not able to accept the connection at that time because either it is not listening or its backlog is full (there is no way to differentiate which). So, when you are connecting to the localhost, you will pretty much always get a WSAECONNREFUSED
error when connecting to a non-listening port because you are connecting to the same machine and there is no delay in determining the port's listening status. It has nothing to do with firewalls or anti-malwares. This is just normal behavior.