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






Creating an SSL Client Socket

  

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

import javax.net.SocketFactory;
import javax.net.ssl.SSLSocketFactory;

public class Main {
  public static void main(String[] argv) throws Exception {
    int port = 443;
    String hostname = "hostname";
    SocketFactory socketFactory = SSLSocketFactory.getDefault();
    Socket socket = socketFactory.createSocket(hostname, port);


    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 Server 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