Simple method to capture HTTP input

Bryan Sant bryan.sant at
Wed Jan 18 13:36:17 MST 2006

On 1/18/06, Ross Werner <ross at> wrote:
> (p.s. this is super-trivial to do in just about any modern programming
> language. It's about four lines of perl, php, and about a dozen in Java.
> The phrase "socket programming" shouldn't scare you away.)

Actually, it's 16 lines of code in Java (ignoring whitespace):


public class NetEcho {

  public static void main(String[] args) throws Exception {
    ServerSocket serverSocket = new ServerSocket(8081);

    while (true) {
      byte[] data = new byte[1024];
      int actualRead = 0;
      Socket clientSocket = serverSocket.accept();
      InputStream is = clientSocket.getInputStream();

      while ((actualRead = > -1)
        System.out.print(new String(data, 0, actualRead));




More information about the PLUG mailing list