import java.net.*; import java.applet.*; import java.io.*; import java.awt.*; import java.lang.*; public class r { public static OutputStream out; public static DataInputStream dis; public static Socket soc; public static byte[] response; public static String host; public static int port; public static int spot; public static void main ( String[] args ) { response=new byte[101]; host="www.cs.uwm.edu"; port=5007; try { System.out.println("entering function"); soc=new Socket(host,port); out=new DataOutputStream(soc.getOutputStream()); InputStream instream=soc.getInputStream(); DataInputStream dis=new DataInputStream(instream); System.out.println("exiting function"); } catch (Exception e) { System.err.println(e); System.exit(1); } try { out.write(5); /* out.write('\n');*/ out.flush(); System.out.println("Request sent.."); } catch (Exception e) { System.err.println(e); System.exit(2); } try { System.out.println("Trying to read socket.."); spot=0; while ( (spot<100) && (response[spot]!='\n') ) { byte b=dis.readByte(); response[spot]=b; spot=spot+1; } System.out.println("socket read"); } catch (Exception e) { System.err.println(e); System.exit(5); } try { System.out.println("Trying to display response"); spot=0; while ( spot<100 ) { System.out.println(response[spot]); spot=spot+1; } System.out.println("response printed"); } catch (Exception e) { System.err.println(e); System.exit(6); } } }