static void serve(Socket socket)
    {
        try
        {
            socket.setTcpNoDelay(true);
            int x = 0;
            byte[] buffer = new byte[2048];
            while(true)
            {
                int r = socket.getInputStream().read(buffer);
                if(r==-1)
                    break;

                // read the bytes at least once, even though we are not parsing them.
                for(int i=0; i<r; i++)
                    x += buffer[i];

                // a very crude verification that read() got one GET request
                if(r<4 || buffer[r-4]!='\r' || buffer[r-3]!='\n' || buffer[r-2]!='\r' || buffer[r-1]!='\n' )
                    throw new Exception("not ended in CR LF CR LF as expected");

                OutputStream out = socket.getOutputStream();
                out.write(responseBytes);
                out.flush();
            }
            System.out.println(x);
            socket.close(); // should be in finally{}
        }
        catch (Exception e)
        {
            System.out.println(e.toString());
        }
    }