Creating an SSL Server Socket : SSLServerSocket « Network « Java Tutorial






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();
  }
}








19.16.SSLServerSocket
19.16.1.SSL Server Demo
19.16.2.Creating an SSL Client Socket
19.16.3.Creating an SSL Server Socket
19.16.4.Secure Communication with JSSE