Package java.net

Examples of java.net.Socket.connect()


    }

    @Override
    public Socket createSocket(String host, int port) throws IOException, UnknownHostException {
        Socket socket = applySettings(createSocket());
        socket.connect(new InetSocketAddress(host, port));
        return socket;
    }

    public Configuration getConf() {
        return this.configuration;
View Full Code Here


                               int port,
                               InetAddress localAddress,
                               int localPort) throws IOException {
        Socket socket = applySettings(createSocket());
        socket.bind(new InetSocketAddress(address, localPort));
        socket.connect(new InetSocketAddress(localAddress, port));
        return socket;
    }

    @Override
    public Socket createSocket(InetAddress host, int port) throws IOException {
View Full Code Here

    }

    @Override
    public Socket createSocket(InetAddress host, int port) throws IOException {
        Socket socket = applySettings(createSocket());
        socket.connect(new InetSocketAddress(host, port));
        return socket;
    }

    @Override
    public Socket createSocket(String host, int port, InetAddress localHost, int localPort)
View Full Code Here

    public void testRepeatedClosedConnections() throws Exception {
        for(int i = 0; i < 100; i++) {
            Socket s = new Socket();
            s.setTcpNoDelay(true);
            s.setSoTimeout(1000);
            s.connect(new InetSocketAddress("localhost", socketPort));
            logger.info("Client opened" + i);
            // Thread.sleep(1);
            assertTrue(s.isConnected());
            assertTrue(s.isBound());
            assertTrue(!s.isClosed());
View Full Code Here

                    // ignore
                }
            };
        } else {
            s = new Socket();
            s.connect(endpoint,3000);
            out = new SocketOutputStream(s);
        }

        closables.add(new Closeable() {
            public void close() throws IOException {
View Full Code Here

            }

            Socket socket = null;
            try {
                socket = new Socket();
                socket.connect(this.socketAddress);
                writeLine0(socket, this.secretKey + " " + command);
                final String result = readLine(socket);
                Main.info("Sent '" + command + "' to " + this.socketAddress + ": " + result, null);
                return 0; // LSB code for everything's fine
            } catch (final ConnectException ce) {
View Full Code Here

        socket.setSoTimeout(timeout);

        SocketAddress localaddr = new InetSocketAddress(localAddress, localPort);
        SocketAddress remoteaddr = new InetSocketAddress(host, port);
        socket.bind(localaddr);
        socket.connect(remoteaddr, timeout);
        return socket;
    }

    public int hashCode() {
        return SocksSocketFactory.class.hashCode();
View Full Code Here

        else {
            Socket socket = socketfactory.createSocket();
            SocketAddress localaddr = new InetSocketAddress(localAddress, localPort);
            SocketAddress remoteaddr = new InetSocketAddress(host, port);
            socket.bind(localaddr);
            socket.connect(remoteaddr, timeout);
            return socket;
        }
    }

    @Override
View Full Code Here

      port = 80;

    SocketAddress sockaddr = new InetSocketAddress(addr, port);
    Socket test = new Socket();
    int timeoutMs = 1000; // 1 second
    test.connect(sockaddr, timeoutMs);
    test.close();
    bool = true;
    return bool;
  }
View Full Code Here

                String request = sb.toString();

                // Send the request to the remote server
                socket = new Socket();
                socket.setSoTimeout(SO_TIMEOUT);
                socket.connect(new InetSocketAddress(clientAddress, 113),
                        CONNECT_TIMEOUT);
                socket.getOutputStream().write(request.getBytes());

                // Read the response
                in = new BufferedReader(new InputStreamReader(socket
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.