/* * Java Network Programming * Copyright (C) 2000 by Jeffrey E. Care (carej@ieee.org) * David Hollinger (hollingd@cs.rpi.edu) * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) any * later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to * * Free Software Foundation, Inc. * 59 Temple Place, Suite 330 * Boston, MA 02111-1307 * USA */ package edu.rpi.cs.netprog.tcp; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.net.Socket; import java.util.Hashtable; public class InputManager extends Thread { //---------------------------------------------------------------------------- // Private Data Members //---------------------------------------------------------------------------- private BufferedReader keyboard; private PrintWriter server; //---------------------------------------------------------------------------- // Public Constructor //---------------------------------------------------------------------------- public InputManager (InputStream istream, Socket socket) { try { keyboard = new BufferedReader (new InputStreamReader (istream)); server = new PrintWriter (socket.getOutputStream ()); setPriority (MIN_PRIORITY); setDaemon (true); start (); } catch (Exception exp) { System.err.println ("Error opening socket streams"); exp.printStackTrace (); System.exit (0); } } //---------------------------------------------------------------------------- // Public Overridden Thread Methods //---------------------------------------------------------------------------- public void run () { try { String line; while ((line = keyboard.readLine ()) != null) { server.print (line); server.print ("\r\n"); server.flush (); } } catch (Exception exp) { exp.printStackTrace (); } } }