FileDocCategorySizeDatePackage
MultiJabberServer.javaAPI DocExample4187Mon Apr 06 18:10:22 BST 1998None

ServeOneJabber

public class ServeOneJabber extends Thread

Fields Summary
private Socket
socket
private BufferedReader
in
private PrintWriter
out
Constructors Summary
public ServeOneJabber(Socket s)

    socket = s;
    in = 
      new BufferedReader(
        new InputStreamReader(
          socket.getInputStream()));
    // Enable auto-flush:
    out = 
      new PrintWriter(
        new BufferedWriter(
          new OutputStreamWriter(
            socket.getOutputStream())), true);
    // If any of the above calls throw an 
    // exception, the caller is responsible for
    // closing the socket. Otherwise the thread
    // will close it.
    start(); // Calls run()
  
Methods Summary
public voidrun()

    try {
      while (true) {  
        String str = in.readLine();
        if (str.equals("END")) break;
        System.out.println("Echoing: " + str);
        out.println(str);
      }
      System.out.println("closing...");
    } catch (IOException e) {
    } finally {
      try {
        socket.close();
      } catch(IOException e) {}
    }