rt

Reader's Theatre
Log | Files | Refs | README | LICENSE

clienttask.java (761B)


      1 package space.nocebo;
      2 
      3 import java.net.*;
      4 import java.io.*;
      5 
      6 public class clienttask implements Runnable{
      7 	private Socket con;
      8 
      9 	public clienttask(Socket s) {
     10 		con = s;
     11 	}
     12 	@Override
     13 	public void run() {
     14 		try {
     15 			DataOutputStream outputStr = new DataOutputStream(
     16 				new BufferedOutputStream(con.getOutputStream()));
     17 			String s = "";
     18 			while (s.compareTo("q") != 0) {
     19 				BufferedReader stdin = new BufferedReader(
     20 					new InputStreamReader(System.in));
     21 				if ((s = stdin.readLine()) != null && s.length() != 0) {
     22 					outputStr.writeUTF(s);
     23 					outputStr.flush();
     24 				}
     25 			}
     26 
     27 			outputStr.writeUTF(s);
     28 			outputStr.flush();
     29 
     30 			outputStr.close();
     31 			client.cexit = 1;
     32 		} catch (IOException ex) {
     33 			System.out.println("IOException: " + ex);
     34 		}
     35 	}
     36 }