Reconnect on error and is thread-safe.

@param host Host
@param port Port
@return QConnector
428457
public static QConnectorSync create(final String host, final int port) {
		return create(host, port, true, true);
	}
291370
public void init(final Connection connection, final String devname, final String host,
	    	final String port) throws DevFailed {
		connection.url = new TangoUrl(buildUrlName(host, port, devname));
		connection.devname = connection.url.devname;
		connection.setDevice_is_dbase(false);

		// Check if connection is possible
		if (connection.url.protocol == TANGO) {
	    	connection.ior = get_exported_ior(connection);
		}
   	}
1250322
public static RedisURI create(String host, int port) {
        return Builder.redis(host, port).build();
    }
1000450
public Task reconnectHost_Task(HostConnectSpec hcs) throws InvalidName, InvalidLogin, InvalidState, HostConnectFault, RuntimeFault, RemoteException {
        return reconnectHost_Task(hcs, null);
    }
170350
public String connectAndBind(String host, int port,
            BindParameter bindParam) 
            throws IOException {
        return connectAndBind(host, port, bindParam, 60000);
    }
792765
@Override
    public Socket createSocket(String host, int port) throws IOException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, "SocketFactory attempting to create socket for host: " + host + " port: " + port);

        // check for SSL addresses
        if (Util.isEncodedHost(host, HOST_PROTOCOL)) {
            String sslConfigName = Util.decodeHostInfo(host);
            host = Util.decodeHost(host);
            return createSSLSocket(host, (char) port, sslConfigName);
        } else {
            return createPlainSocket(host, port);
        }
    }
736086
function(port, host, opts) {
  if (!(this instanceof Connector)) {
    return new Connector(port, host, opts);
  }

  EventEmitter.call(this);
  this.port = port;
  this.host = host;
  this.opts = opts || {};

  this.adaptor = new Adaptor(this.opts);
}
586072
def _try_reconnect(self):
        """"""

        try:
            if self.connection_interrupted:
                self.connect_direct(self.connection_string, force=True)
                self.connection_interrupted = False
                self.connected = True

                # Reenable streaming interface if that was open before as well
                if self._reports is not None:
                    self._loop.run_coroutine(self.adapter.open_interface(0, 'streaming'))

                # Reenable tracing interface if that was open before as well
                if self._traces is not None:
                    self._loop.run_coroutine(self.adapter.open_interface(0, 'tracing'))
        except HardwareError as exc:
            self._logger.exception("Error reconnecting to device after an unexpected disconnect")
            raise HardwareError("Device disconnected unexpectedly and we could not reconnect", reconnect_error=exc) from exc
376439
public TTransport openTransport(String host, int port) throws TTransportException
    {
        TSocket socket = new TSocket(host, port);
        TTransport transport = new TFramedTransport(socket, thriftFramedTransportSizeMb * 1024 * 1024);
        transport.open();
        return transport;
    }
203324
function (host, port, onError) {
	
	var proxy = undefined;
	
	var options = {target: 'ws://' + host, ws: true};
	LOG.warn('create new ws proxy at port: ' + port + ' options: ', 'SR.Proxy');
	LOG.warn(options, 'SR.Proxy');
	
	proxy = httpProxy.createServer(options);
		
	// install error handler (NOTE: very imporant for stability)
	proxy.on('error', function (err, req, res) {
		UTIL.safeCall(onError, err);
	});
	
	// be notified when closed
	// ref: https://github.com/nodejitsu/node-http-proxy
	proxy.on('close', function (req, socket, head) {
  		// view disconnected websocket connections
  		console.log('Client disconnected');
	});	

	// store proxy for later uses
	// NOTE: not used directly
	l_proxies[host] = proxy;

	// record local port for future references
	// NOTE: this is an important step for future queries of the proxy
	// and may need to be performed before setting the on('xx') handler(s) 
	// BUG: seems like 'local_port' info will disappear under certain circumstances
	// (after entries are shutdown & restart many times)
	l_proxies[host].local_port = port;
		
	// start to listen for requests	
	// NOTE: listen may fail or cause errors that could trigger this proxy be removed from list
	proxy.listen(port);	

	return proxy;
	
	/* 2nd version
	proxy = httpProxy.createProxyServer(options);
	
	proxy.on('error', function (e) {
		UTIL.safeCall(onError, e);
	});
	
	// start a new HTTP server just for websocket connections
	var proxyServer = http.createServer(function (req, res) {
		LOG.warn('incoming request to standalone HTTP ws proxy', 'SR.Proxy');
		proxy.web(req, res);
	});

	//
	// Listen to the `upgrade` event and proxy the
	// WebSocket requests as well.
	//
	proxyServer.on('upgrade', function (req, socket, head) {
		try {
			proxy.ws(req, socket, head);
		}
	    catch (e) {
			LOG.error('websocket error:', 'SR.Proxy');
			LOG.error(e, 'SR.Proxy');
		}
			
	});

	// TODO: may need to provide a unique port for it
	// TODO: record this http server?
	LOG.warn('starting ws proxy at port: ' + port, 'SR.Proxy');
	proxyServer.listen(port);
	
	return proxy;
	*/
}
915999
protected boolean isConnected(final String host, final int port, final int timeoutInMs,
      final ErrorHandler errorHandler) {
    final Socket socket = new Socket();
    return isConnected(socket, host, port, timeoutInMs, errorHandler);
  }
456961
def retry(self):
        """"""
        self.stream = None
        self.config.loop.call_later(RETRY_TIMER, self.start)
        _LOGGER.debug('Reconnecting to %s', self.config.host)
112600
public void setSocketProxy(String host, int port) {
        if (config == null) {
            config = new AipClientConfiguration();
        }
        this.config.setProxy(host, port, Proxy.Type.SOCKS);
    }
1177174
public XComponentContext connect(String host, int port) throws BootstrapException {
        String unoConnectString = "uno:socket,host=" + host + ",port=" + port + ";urp;StarOffice.ComponentContext";
        return connect(unoConnectString);
    }
41653
def retryNextHost(self, connector=None):
        
        if not self.continueTrying:
            msg = "TxMongo: Abandoning {0} on explicit request.".format(connector)
            log.msg(msg)
            return

        if connector is None:
            if self.connector is None:
                raise ValueError("TxMongo: No additional connector to retry.")
            else:
                connector = self.connector

        delay = False
        self.__index += 1

        if self.__index >= len(self.__allnodes):
            self.__index = 0
            delay = True

        connector.host, connector.port = self.__allnodes[self.__index]

        if delay:
            self.retry(connector)
        else:
            connector.connect()
615157
public function connect($host, $port, Connection $connection, $timeout = 5)
    {
        $deferred = new Deferred();
        $this->disconnect()
            ->then(function () use ($deferred, $host, $port, $connection, $timeout) {
                $this->establishConnection($host, $port, $connection, $timeout)
                    ->then(function () use ($deferred) {
                        $deferred->resolve($this);
                    })
                    ->otherwise(function (\Exception $error) use ($deferred) {
                        $deferred->reject($error);
                    });
            })
            ->otherwise(function () use ($deferred) {
                $deferred->reject($this);
            });

        return $deferred->promise();
    }
1204065
def is_connectable(port, host="localhost"):
    
    socket_ = None
    try:
        socket_ = socket.create_connection((host, port), 1)
        result = True
    except _is_connectable_exceptions:
        result = False
    finally:
        if socket_:
            socket_.close()
    return result