Java 8 SocketFactory - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 SocketFactory class.

This code example shows how to use the following methods:createSocket
    public Socket createSocket(String s, int i, InetAddress inaddr, int j) throws IOException {
        return factory.createSocket(s, i, inaddr, j);
    } 
 
    public Socket createSocket(String s, int i) throws IOException {
        return factory.createSocket(s, i);
    } 
 
    public String[] getDefaultCipherSuites() {
        return factory.getDefaultCipherSuites();
    } 
 
    public String[] getSupportedCipherSuites() {
        return factory.getSupportedCipherSuites();
    } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:createSocket
        return delegate.getSupportedCipherSuites();
    } 
 
    @Override 
    public Socket createSocket(String host, int port) throws IOException {
        return delegate.createSocket(host, port);
    } 
 
    @Override 
    public Socket createSocket(InetAddress address, int port) throws IOException {
        return delegate.createSocket(address, port);
    } 
 
    @Override 
    public Socket createSocket(String host, int port, InetAddress localAddress, int localPort) throws IOException {
        return delegate.createSocket(host, port, localAddress, localPort);
    } 
 
    @Override 
    public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort) throws IOException {
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:createSocket
    public Socket createSocket(String host, int port) throws IOException {
        this.initSSLContext();
        InetAddress address = InetAddress.getByName(host);
 
        SSLSocketFactory socketFactory = this.sslContext.getSocketFactory();
        SSLSocket socket = (SSLSocket) socketFactory.createSocket(address, port);
        if (this.jsseSecurityDomain.getProtocols() != null)
            socket.setEnabledProtocols(this.jsseSecurityDomain.getProtocols());
        if (this.jsseSecurityDomain.getCipherSuites() != null)
            socket.setEnabledCipherSuites(this.jsseSecurityDomain.getCipherSuites());
        socket.setNeedClientAuth(this.jsseSecurityDomain.isClientAuth());
        return socket;
    } 
 
    @Override 
    public Socket createSocket(String host, int port, int timeout) throws IOException, TIMEOUT {
        this.initSSLContext();
        InetAddress address = InetAddress.getByName(host);
 
        SSLSocketFactory socketFactory = this.sslContext.getSocketFactory();
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:createSocket
    public Socket createSocket() throws IOException {
        return factory.createSocket();
    } 
 
    public Socket createSocket(InetAddress inaddr, int i, InetAddress inaddr1, int j) throws IOException {
        return factory.createSocket(inaddr, i, inaddr1, j);
    } 
 
    public Socket createSocket(InetAddress inaddr, int i) throws IOException {
        return factory.createSocket(inaddr, i);
    } 
 
    public Socket createSocket(String s, int i, InetAddress inaddr, int j) throws IOException {
        return factory.createSocket(s, i, inaddr, j);
    } 
 
    public Socket createSocket(String s, int i) throws IOException {
        return factory.createSocket(s, i);
    } 
 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:createSocket
    public Socket createSocket() throws IOException {
        return factory.createSocket();
    } 
 
    public Socket createSocket(InetAddress inaddr, int i, InetAddress inaddr1, int j) throws IOException {
        return factory.createSocket(inaddr, i, inaddr1, j);
    } 
 
    public Socket createSocket(InetAddress inaddr, int i) throws IOException {
        return factory.createSocket(inaddr, i);
    } 
 
    public Socket createSocket(String s, int i, InetAddress inaddr, int j) throws IOException {
        return factory.createSocket(s, i, inaddr, j);
    } 
 
    public Socket createSocket(String s, int i) throws IOException {
        return factory.createSocket(s, i);
    } 
 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:createSocket
        // use a non-existing provider so that the DefaultSSLSocketFactory 
        // will be used, and then test against it. 
        Security.setProperty("ssl.SocketFactory.provider", "foo.NonExistant");
        SSLSocketFactory fac = (SSLSocketFactory)SSLSocketFactory.getDefault();
        try { 
            fac.createSocket();
        } catch(SocketException se) {
            // if exception caught, then it's ok 
            System.out.println("Throw SocketException");
            se.printStackTrace();
            return; 
        } 
        throw new Exception("should throw SocketException");
        // if not caught, or other exception caught, then it's error 
    } 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:createSocket
  } 
 
  @Override 
  public Socket createSocket(String host, int port) throws IOException,
      UnknownHostException { 
    return sslFactory.createSocket(host, port);
  } 
 
  @Override 
  public Socket createSocket(InetAddress host, int port) throws IOException {
    return sslFactory.createSocket(host, port);
  } 
 
  @Override 
  public Socket createSocket(String host, int port, InetAddress localHost,
      int localPort) throws IOException, UnknownHostException {
    return sslFactory.createSocket(host, port, localHost, localPort);
  } 
 
  @Override 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:createSocket
			return new AndroidSSLSocketFactory(sslContext);
		} 
	} 
 
	protected Socket newSocket(boolean pSSL, String pHostName, int pPort) throws UnknownHostException, IOException {
		final Socket s = socketFactory.createSocket(pHostName, pPort);
		if(pSSL) {
			return getSSLSocketFactory().createSocket(s, pHostName, pPort, true);
		} else { 
			return s;
		} 
	} 
	 
	private static final String userAgent = USER_AGENT + " (Lite HTTP Transport)";
	private boolean ssl;
	private String hostname;
	private String host;
	private int port;
	private String uri;
	private Socket socket;
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:createSocket, getDefaultCipherSuites, getSupportedCipherSuites
 
        assertNotNull(ssfactory.getDefaultCipherSuites());
        assertNotNull(ssfactory.getSupportedCipherSuites());
        assertNotNull(ssfactory.createServerSocket());
 
        assertNotNull(sfactory.getDefaultCipherSuites());
        assertNotNull(sfactory.getSupportedCipherSuites());
        assertNotNull(sfactory.createSocket());
    } 
 
    public void testSocketCreation() throws Throwable { 
        SSLSocketFactory socketFactory
            = new SSLSocketFactoryImpl(JSSETestData.getSSLParameters()); 
        SSLServerSocketFactory serverSocketFactory
            = new SSLServerSocketFactoryImpl(JSSETestData.getSSLParameters()); 
 
        String[] enabled = {"TLS_RSA_WITH_RC4_128_MD5"};
        for (int i=0; i<4; i++) {
            SSLServerSocket ssocket;
            switch (i) {
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:createSocket, getDefaultCipherSuites
		r = new BufferedReader(new InputStreamReader(socket.getInputStream(),"UTF-8"));
		w = new PrintWriter(new OutputStreamWriter(socket.getOutputStream(),"UTF-8"));
	} 
	 
	public Socket createSocket() throws UnknownHostException, IOException {
		SSLSocket socket = (SSLSocket) _factory.createSocket(_host, _port);
		socket.setEnabledCipherSuites(_factory.getDefaultCipherSuites());
		socket.setEnabledProtocols(socket.getSupportedProtocols());
		return socket;
	} 
	 
	public void send(String msg) {
		w.println(msg);
		w.flush();
	} 
	 
	public String read() throws IOException {
		return r.readLine();
	} 
	 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 SocketFactory Methods: