Changed socket error handler to handle 'ECONNREFUSED'. In event of ECONNREFUSED the port is available