package examples; import java.net.*; import java.io.*; import java.util.*; public class MyClient { public static void main(String[] args) { try { System.out.print("Connecting to server...."); Socket conn = new Socket(InetAddress.getByName("selenium.cs.pitt.edu"), 3459); System.out.println("done"); Scanner stdin = new Scanner(System.in); Scanner fromServer = new Scanner(conn.getInputStream()); PrintWriter toServer = new PrintWriter(conn.getOutputStream()); String line; do { //read from user System.out.print("Enter text: "); line = stdin.nextLine(); //send to server toServer.println(line); toServer.flush(); //read response from server line = fromServer.nextLine(); System.out.println(line); } while(!line.equals("exit")); fromServer.close(); toServer.close(); conn.close(); } catch(IOException ioe){ioe.printStackTrace();} } }