Correction on the email.  I can get the linux 'telnet' program to work with
the EchoServer, but not my program whose code is listed below.


On 3/12/07, Mark Webb <[EMAIL PROTECTED]> wrote:

I am trying to get the Echo server example working in the 1.1 branch with
a simple telnet application.  I hope to use this echo server for more in the
near future, but I have run into a problem I can't seem to fix.  I start up
the EchoServer example and telnet to port 8080.  I type in something like
"Hello World", and never get anything back.  I am not sure if this is a
problem with the codec, the telnet program or something else.  I even wrote
a simple program that looks like the following:

for( ; ; ){

                Socket socket = new Socket( host, port );
                OutputStream out = socket.getOutputStream();
                InputStream in = socket.getInputStream();

                out.write( "Hello World\r\n".getBytes() );
                out.flush();

                int read = 0;
                byte[] buf = new byte[16];
                while( (read = in.read(buf)) != -1 ){
                    System.out.println( new String(buf,0,read) );
                }

                socket.close();
                Thread.sleep(1000);
            }

The problem is that the first call to in.read(buf) works fine.  The second
call hangs and waits for more data.  I am getting this problem without
modifying the EchoServer code, so I think I need some help.

Thank you.




--
..Cheers
Mark

Reply via email to