Fixed a socket bug which made a new connection not possible after a failed attempt