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

class Client {
    public static void main(String[] args) {
	try {
	    int port = 8000;
	    String hostname = "192.168.1.6";  // Insert your localhost ip
	    SSLSocketFactory socketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
	    //SSLContext ctx = SSLContext.getInstance("SSL");
	    //ctx.init(null, null, null);
	    //SocketFactory socketFactory = ctx.getSocketFactory();
	    SSLSocket socket = (SSLSocket) socketFactory.createSocket(hostname, port);
	    socket.setEnabledProtocols(new String[] {"SSLv3", "TLSv1"});
	    System.out.println("Need client auth: " + socket.getNeedClientAuth());
	    System.out.println("Want client auth: " + socket.getWantClientAuth());
	    socket.startHandshake();

	    // Create streams to securely send and receive data to the server
	    InputStream in = socket.getInputStream();
	    OutputStream out = socket.getOutputStream();
	    
	    PrintWriter writer = new PrintWriter(out);
	    writer.println("Hello world");
	    
	    // Read from in and write to out...
	    // Close the socket 
	    writer.close();
	    in.close(); 
	    out.close();
	} catch(Exception e) {
	    e.printStackTrace();
	    System.out.println(e.getMessage());
	}
    }
} 
