Creating an SSL Server Socket : SSL Server Socket « Network Protocol « Java






Creating an SSL Server Socket

  
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

import javax.net.ServerSocketFactory;
import javax.net.ssl.SSLServerSocketFactory;

public class Main {
  public static void main(String[] argv) throws Exception {
    int port = 443;
    ServerSocketFactory ssocketFactory = SSLServerSocketFactory.getDefault();
    ServerSocket ssocket = ssocketFactory.createServerSocket(port);

    Socket socket = ssocket.accept();

    InputStream in = socket.getInputStream();
    OutputStream out = socket.getOutputStream();

    // Read from in and write to out...

    in.close();
    out.close();
  }
}

   
    
  








Related examples in the same category

1.Creating an SSL Client Socket
2.Secure Communication with JSSE
3.Secure Login based on SSL Server Socket
4.Simple Client for secure Socket
5.Simple server for Secure socket
6.Secure Server
7.SSL Server Demo
8.Secure Client
9.A simple single-threaded proxy server
10.implements HandshakeCompletedListener
11.Cipher Socket