cryptography

profileprapulmutyala
client.java

// File Name Client.java import java.net.*; import java.io.*; import java.util.*; public class Client { public static void main(String [] args) { String serverName = args[0]; int port = Integer.parseInt(args[1]); try { System.out.println("Connecting to Server"); Socket client = new Socket(serverName, port); System.out.println("Just connected to Server"); OutputStream outToServer = client.getOutputStream(); DataOutputStream out = new DataOutputStream(outToServer); DataOutputStream out1 = new DataOutputStream(outToServer); Scanner myObj = new Scanner(System.in); System.out.println("Enter a message"); String line = myObj.nextLine(); // out.writeUTF("Client: Hello"); out.writeUTF(line); InputStream inFromServer = client.getInputStream(); DataInputStream in = new DataInputStream(inFromServer); System.out.println("Server:" + in.readUTF()); out1.writeUTF("Thank You"); client.close(); } catch (IOException e) { e.printStackTrace(); } } }