Secure Client : SSL Server Socket « Network Protocol « Java






Secure Client

   
import java.net.*;
import java.io.*;
import javax.net.*;
import java.security.*;
import javax.net.ssl.*;
import javax.crypto.*;

public class SecureClient {
   public static final int PORT = 10000;
   public static void main(String[] args) throws Exception {
      String host = "127.0.0.1";

      SocketFactory sf = SSLSocketFactory.getDefault();
      SSLSocket sock = (SSLSocket) sf.createSocket(host, PORT);
      System.out.println("Server connected");

      InputStream rawIn = sock.getInputStream( );
      BufferedReader in = new BufferedReader(new InputStreamReader(rawIn));
      System.out.println(in.readLine( ));
      sock.close() ;
   }
}

   
    
  








Related examples in the same category

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