AlexO #1 make sure you close the socket that failed the connection afterwards. Otherwise it is still occupying that port.