Code example for Socket

Methods: bindconnectsetReuseAddresssetSoTimeout

0
    public Socket createSocket(final HttpParams params) {
        return new Socket();
    } 
 
    public Socket createSocket() {
        return new Socket();
    } 
 
    /** 
     * @since 4.1 
     */ 
    public Socket connectSocket(
            final Socket socket,
            final InetSocketAddress remoteAddress,
            final InetSocketAddress localAddress,
            final HttpParams params) throws IOException, ConnectTimeoutException {
        if (remoteAddress == null) {
            throw new IllegalArgumentException("Remote address may not be null");
        } 
        if (params == null) {
            throw new IllegalArgumentException("HTTP parameters may not be null");
        } 
        Socket sock = socket;
        if (sock == null) {
            sock = createSocket();
        } 
        if (localAddress != null) {
            sock.setReuseAddress(HttpConnectionParams.getSoReuseaddr(params));
            sock.bind(localAddress);
        } 
        int connTimeout = HttpConnectionParams.getConnectionTimeout(params);
        int soTimeout = HttpConnectionParams.getSoTimeout(params);
 
        try { 
            sock.setSoTimeout(soTimeout);
            sock.connect(remoteAddress, connTimeout);
        } catch (SocketTimeoutException ex) {
            throw new ConnectTimeoutException("Connect to " + remoteAddress + " timed out");
        } 
        return sock;
    } 
Connect your IDE to all the code out there  Get Codota for Java