import java.net.*; import java.io.*; import java.util.concurrent.*; import java.nio.channels.*; import java.lang.*; public class hw1_client { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("Kazan's Slow boring Java network directory listing client."); System.out.println("Usage: java hw1_client "); try { Socket cl_socket = new Socket("localhost", 9877); DataOutputStream outToServer = new DataOutputStream(cl_socket.getOutputStream()); DataInputStream inFromServer = new DataInputStream(cl_socket.getInputStream()); String readstr; while (true) { readstr = inFromServer.readLine(); if (readstr != "$READY$") { System.out.println("Received OK to proceed from server."); break; } } outToServer.writeChars("/home/Kazan\n"); outToServer.flush(); while (true) { readstr = inFromServer.readLine(); if (readstr != "$END$" || readstr == null) break; System.out.println(readstr); } outToServer.writeChars("STOP SERVER\n"); outToServer.flush(); } catch (IOException e) { System.out.println(e); } } }