Client:
Code:import java.io.*; import java.net.*; class Client3{ public static void main(String[] args) { String clientCar=""; String clientBranch=""; String clientDriver=""; String clientPasswd=""; DataOutputStream out; DataInputStream in; try { Socket t = new Socket("127.0.0.1", 9001); in = new DataInputStream(t.getInputStream()); out = new DataOutputStream(t.getOutputStream()); BufferedReader br = new BufferedReader (new InputStreamReader(System.in)); boolean more = true; System.out.println(in.readUTF()); while (more) { clientCar = in.readUTF(); clientBranch = in.readUTF(); clientDriver = in.readUTF(); clientPasswd = in.readUTF(); if ((clientCar == null) || (clientBranch == null) || (clientDriver == null) || (clientPasswd == null)) more = false; else out.writeUTF(clientCar+"\n"); out.flush(); out.writeUTF(clientBranch+"\n"); out.flush(); out.writeUTF(clientDriver+"\n"); out.flush(); out.writeUTF(clientPasswd+"\n"); out.flush(); } } catch(IOException e){ System.out.println("Error" + e); } } }




Reply With Quote
