Java 8 ServerSocketFactory - 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 ServerSocketFactory class.

This code example shows how to use the following methods:createServerSocket
This code example shows how to use the following methods:createServerSocket
        System.setProperty("javax.net.ssl.keyStorePassword", "passphrase");
        System.setProperty("javax.net.ssl.keyStore",
                System.getProperty("test.src", "./") + "/../../ssl/etc/keystore");
        SSLServerSocketFactory sslssf =
                (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
        final ServerSocket server = sslssf.createServerSocket(0);
        System.out.println(server.getLocalPort());
        System.out.flush();
        Thread t = new Thread() {
            public void run() { 
                try { 
                    Thread.sleep(30000);
                    server.close();
                } catch (Exception e) {
                    ; 
                } 
                throw new RuntimeException("Timeout");
            } 
        }; 
        t.setDaemon(true);
5
CodeRank
This code example shows how to use the following methods:createServerSocket
    public ServerSocket createSocket (int port, int backlog,
                                      InetAddress ifAddress)
        throws IOException 
    {    
        if (!initialized) init();
        ServerSocket socket = sslProxy.createServerSocket(port, backlog,
                                                          ifAddress);
        initServerSocket(socket);
        return socket;
    } 
     
    public Socket acceptSocket(ServerSocket socket)
        throws IOException 
    { 
        SSLSocket asock = null;
        try { 
             asock = (SSLSocket)socket.accept();
        } catch (SSLException e){
          throw new SocketException("SSL handshake error" + e.toString());
        } 
3
CodeRank
This code example shows how to use the following methods:createServerSocket
		SSLContext ctx = getSSLContext(serverStorePath, serverStorePassword,
				caStorePath, caStorePassword);
 
		SSLServerSocketFactory factory = ctx.getServerSocketFactory();
		SSLServerSocket serverSocket = (SSLServerSocket) factory
				.createServerSocket(port);
 
		serverSocket.setNeedClientAuth(true);
		return serverSocket;
	} 
 
	/** 
	 * 取得SSLContext 
	 *  
	 * @param keyStorePath 
	 * @param keyStorePassword 
	 * @param trustStorePath 
	 * @param trustStorePassword 
	 * @return 
	 * @throws Exception 
4
CodeRank
This code example shows how to use the following methods:createServerSocket
		if (port <= 1024) {
			throw new IllegalArgumentException("Ports under 1024 are reserved!");
		} 
		_port = port;
		SSLServerSocketFactory sslServerSocketFactory = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
		_socket = sslServerSocketFactory.createServerSocket(port);
		 
 
		//_socket = new ServerSocket(port);//(SSLServerSocket) sslServerSocketFactory.createServerSocket(port); 
		//_socket.setEnabledCipherSuites(sslServerSocketFactory.getDefaultCipherSuites()); 
		 
		//System.err.println("SERVER"); 
		//for(String s : _socket.getEnabledCipherSuites()) 
		//	System.out.println(s); 
		 
		try { 
			_b = new CalendarBackend();	
			_e = new EventSuggester(_b);
			_m = new EmailMonitor(_b, ShiftyProperties.getValue("HOST"), ShiftyProperties.getValue("APP_EMAIL"), ShiftyProperties.getValue("EMAIL_PASSWORD"));
		} catch (ClassNotFoundException e) {
4
CodeRank
This code example shows how to use the following methods:createServerSocket
      SSLServerSocket s;
       
      SSLServerSocketFactory sslSrvFact =
        (SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
         
      s = (SSLServerSocket)sslSrvFact.createServerSocket(port);
       
      return s;
    } 
    catch (SocketException scktEx)
    { 
      throw new RuntimeContainedException(scktEx,
                                          "SSL not initialised - check properties"); 
    } 
  } 
 
	public String getProtocolName()
	{ 
		return protocolName__;
	} 
4
CodeRank
This code example shows how to use the following methods:createServerSocket
    } 
 
    /* Added by Daniel J. Martinez Manzano <dani@dif.um.es> */ 
    public SSLServerSocket createSSLServerSocket(int port, int backlog,
            InetAddress bindAddress) throws IOException {
        return (SSLServerSocket) sslServerSocketFactory.createServerSocket(
                port, backlog, bindAddress);
    } 
 
    /* Added by Daniel J. Martinez Manzano <dani@dif.um.es> */ 
    public SSLSocket createSSLSocket(InetAddress address, int port)
            throws IOException { 
        return (SSLSocket) sslSocketFactory.createSocket(address, port);
    } 
 
    /* Added by Daniel J. Martinez Manzano <dani@dif.um.es> */ 
    public SSLSocket createSSLSocket(InetAddress address, int port,
            InetAddress myAddress) throws IOException {
        return (SSLSocket) sslSocketFactory.createSocket(address, port,
                myAddress, 0);
4
CodeRank
This code example shows how to use the following methods:createServerSocket
	protected ServerSocket getServerSocket(int port) throws Exception {
		 
		SSLServerSocketFactory ssf =
			(SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
		 
		return ssf.createServerSocket(port);
	} 
 
} 
4
CodeRank
This code example shows how to use the following methods:createServerSocket
    } 
 
    /* Added by Daniel J. Martinez Manzano <dani@dif.um.es> */ 
    public SSLServerSocket createSSLServerSocket(int port, int backlog,
            InetAddress bindAddress) throws IOException {
        return (SSLServerSocket) sslServerSocketFactory.createServerSocket(
                port, backlog, bindAddress);
    } 
 
    /* Added by Daniel J. Martinez Manzano <dani@dif.um.es> */ 
    public SSLSocket createSSLSocket(InetAddress address, int port)
            throws IOException { 
        return (SSLSocket) sslSocketFactory.createSocket(address, port);
    } 
 
    /* Added by Daniel J. Martinez Manzano <dani@dif.um.es> */ 
    public SSLSocket createSSLSocket(InetAddress address, int port,
            InetAddress myAddress) throws IOException {
        return (SSLSocket) sslSocketFactory.createSocket(address, port,
                myAddress, 0);
5
CodeRank
This code example shows how to use the following methods:createServerSocket
			int port = Integer.parseInt(p);
			 
			SSLServerSocketFactory sslserversocketfactory =
                (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
			 sslserversocket =
                (SSLServerSocket) sslserversocketfactory.createServerSocket(port);
			final String[] enabledCipherSuites = { "SSL_DH_anon_WITH_RC4_128_MD5" };
			sslserversocket.setEnabledCipherSuites(enabledCipherSuites);
 
			 
		} catch (IOException e) {
			e.printStackTrace();
			throw new OpenAS2Exception(e);
		} catch (NumberFormatException e) {
			e.printStackTrace();
			throw new OpenAS2Exception("error converting portid parameter " + e);
		} 
		userid = (String) parameters.get("userid");
		if (userid == null || userid.length() < 1)
			throw new OpenAS2Exception("missing userid parameter"); 
4
CodeRank

Related Java 8 ServerSocketFactory Questions & Answers:

See Code Examples for Java 8 ServerSocketFactory Methods: