in the Echo Server's messageReceived method, I put a session.close() call
in, and everything works fine.
On 3/12/07, Mark Webb <[EMAIL PROTECTED]> wrote:
I believe that is exactly what the problem is. Should EchoServer close
the connection, or is it designed to just read forever?
On 3/12/07, James Im <[EMAIL PROTECTED]> wrote:
>
> I believe that if the Echoserver does not close the connection, the
> method read() in the client will not return -1 and will wait for more
> data.
>
> You probably have read the whole String.
>
> Mark Webb wrote:
> >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.
> >>
> >>
> >
> >
>
> _________________________________________________________________
> Download din yndlingsmusik på MSN Music: http://www.msn.dk/music - det
> er
> nemt og billigt
>
>
--
..Cheers
Mark
--
..Cheers
Mark