import java.net.*;
import java.io.*;

// A pure 1.1 variation of a utility that appears in
// Core Web Programming from Prentice Hall Publishers.
// May be freely used or adapted.
// 1998 Marty Hall, http://www.apl.jhu.edu/~hall/java/.

/** A shorthand way to create BufferedReaders and
 *  PrintWriters associated with a Socket.
 */

public class SocketUtil {

  //----------------------------------------------------
  /** Make a BufferedReader to get incoming data.
   */
  
  public static BufferedReader getBufferedReader
                        (Socket s) throws IOException {
    return(new BufferedReader(
	     new InputStreamReader(
	       s.getInputStream())));
  }

  //----------------------------------------------------
  /** Make a PrintWriter to send outgoing data.
   *  This PrintWriter will automatically flush stream
   *  when println is called.
   */
  
  public static PrintWriter getPrintWriter(Socket s)
      throws IOException {
    // 2nd argument of true means autoflush
    return(new PrintWriter(s.getOutputStream(), true));
  }
}

