| Socket socket;String host;
 BufferedReader in;
 PrintStream out;
 ......//later on in code //Client it to try to connect to host over predetermined 
                      port//you should save the socket in a 
                      CLASS (OOP design!)
 socket = new Socket(host, 50001);
 
 
 //Open up stream to write out messages over socket
 //you should again save in a CLASS
 out = new PrintStream(socket.getOutputStream());
 //Open up stream to recieve any messages over socket 
                      from//server. Again should save in a CLASS
 in = new BufferedReader(new InputStreamReader(socket.getInputStream()) 
                      );
   .....//later in code //Now you can read using in or write using out to the 
                      chat //server using information from your GUI the user is using.
 
 //example....send the text stored in the string S
 out.println(S);
 //example....reading in informationin.readLine();
     }
 |