import java.io.*; import java.net.*; public class Client { public static void main(String[] args) throws IOException { Socket socket = null; PrintWriter out = null; String host = null; if (args.length == 1) { host = args[0]; } else { System.err.println("usage: Client host"); System.exit(1); } try { socket = new Socket(host, 5432); out = new PrintWriter(socket.getOutputStream(), true); } catch (UnknownHostException e) { System.err.println("Don't know about host: host."); System.exit(1); } catch (IOException e) { System.err.println("Couldn't get I/O for the connection to: "+host+"."); System.exit(1); } BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in)); String fromUser; while ((fromUser = stdIn.readLine()) != null) { out.println(fromUser); } } }