Package javax.net

Examples of javax.net.SocketFactory.createSocket()


        //
        final SocketFactory sslSocketFactory = getDefaultClientSocketFactory();
        // Create the SSLSocket
        //
        final SSLSocket sslSocket = (SSLSocket)
            sslSocketFactory.createSocket(host, port);
        // Set the SSLSocket Enabled Cipher Suites
        //
        final String enabledCipherSuites =
            System.getProperty("javax.rmi.ssl.client.enabledCipherSuites");
        if (enabledCipherSuites != null) {
View Full Code Here


                public Socket run() throws IOException {
                    SocketFactory sf = SocketFactory.getDefault();
                    InetSocketAddress sockAddr = new InetSocketAddress(
                            slaveAddress.getHostAddress(),
                            slaveAddress.getPortNumber());
                    Socket s_temp = sf.createSocket();
                    s_temp.connect(sockAddr, timeout_);
                    return s_temp;
                }
            });
        } catch(PrivilegedActionException pea) {
View Full Code Here

        System.setProperty("javax.net.ssl.keyStore", certBase + "/" + "client.ks");
        System.setProperty("javax.net.ssl.keyStorePassword", "password");
        System.setProperty("javax.net.ssl.keyStoreType", "jks");

        SocketFactory factory = SSLSocketFactory.getDefault();
        return factory.createSocket(host, port);
    }

    public void stompConnectTo(String host, int port) throws Exception {
        StompConnection stompConnection = new StompConnection();
        stompConnection.open(createSocket(host, port));
View Full Code Here

        default:
            // Assumes cleartext for undefined values
            sf = SocketFactory.getDefault();
            break;
        }
        return sf.createSocket(server_, port_);
    }

}
View Full Code Here

        System.setProperty("javax.net.ssl.keyStore", certBase + "/client.ks");
        System.setProperty("javax.net.ssl.keyStorePassword", "password");
        System.setProperty("javax.net.ssl.keyStoreType", "jks");

        SocketFactory factory = SSLSocketFactory.getDefault();
        return factory.createSocket(host, port);
    }

    public void stompConnectTo(String connectorName, String extraHeaders) throws Exception {
        String host = broker.getConnectorByName(connectorName).getConnectUri().getHost();
        int port = broker.getConnectorByName(connectorName).getConnectUri().getPort();
View Full Code Here

  private static Socket createSocket(String host, int port, boolean ssl)
      throws UnknownHostException, IOException {
    SocketFactory sf = ssl ? SSLSocketFactory.getDefault() : SocketFactory
        .getDefault();
    Socket socket = sf.createSocket(host, port);
    socket.setKeepAlive(true); // enable TCP KeepAlive packets
    // There are more socket parameters that could be set by configuration:
    // socket.setReuseAddress(true);
    // socket.setSoTimeout(...)
    // socket.setTcpNoDelay(...)
View Full Code Here

            throw new IllegalArgumentException("Parameters may not be null");
        }
        int timeout = params.getConnectionTimeout();
        SocketFactory socketfactory = getSSLContext().getSocketFactory();
        if (timeout == 0) {
            return socketfactory.createSocket(host, port, localAddress, localPort);
        } else {
            Socket socket = socketfactory.createSocket();
            SocketAddress localaddr = new InetSocketAddress(localAddress, localPort);
            SocketAddress remoteaddr = new InetSocketAddress(host, port);
            socket.bind(localaddr);
View Full Code Here

      throw new IllegalArgumentException("Parameters may not be null");
    }
    int timeout = params.getConnectionTimeout();
    SocketFactory socketfactory = getSSLContext().getSocketFactory();
    if (timeout == 0) {
      return socketfactory.createSocket(host, port, localAddress,
          localPort);
    } else {
      Socket socket = socketfactory.createSocket();
      SocketAddress localaddr = new InetSocketAddress(localAddress,
          localPort);
View Full Code Here

    SocketFactory socketfactory = getSSLContext().getSocketFactory();
    if (timeout == 0) {
      return socketfactory.createSocket(host, port, localAddress,
          localPort);
    } else {
      Socket socket = socketfactory.createSocket();
      SocketAddress localaddr = new InetSocketAddress(localAddress,
          localPort);
      SocketAddress remoteaddr = new InetSocketAddress(host, port);
      socket.bind(localaddr);
      socket.connect(remoteaddr, timeout);
View Full Code Here

                resetHeader(request);
                if (!conn.isOpen()) {
                    Socket socket = null;
                    if ("https".equals(targetHost.getSchemeName())) {
                        SocketFactory socketFactory = SSLSocketFactory.getDefault();
                        socket = socketFactory.createSocket(hostname, port);
                    } else {
                        socket = new Socket(hostname, port);
                    }
                    conn.bind(socket, params);
                }
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.