Thank you.  I did not quite understand how the EchoServer worked.  I made
some incorrect assumptions and sent off an email to the list before
investigating how the program worked.



On 3/13/07, Trustin Lee <[EMAIL PROTECTED]> wrote:

Hi Mark,

The echo server example writes back what it received immediately.  I
tested
it with MINA 1.1 and telnet-bsd, and it seems to work perfectly.

The read() call in your code will block until the connection is closed or
data is received.  If you want to close a connection, please let the
server
close the connection, or let the client throw a timeout exception by
setting
SO_TIMEOUT.

HTH,
Trustin

On 3/13/07, Mark Webb <[EMAIL PROTECTED]> wrote:
>
> I think I found a better solution.  I put in a call to session.close()
in
> the messageWritten method of the IoHandler.  This way I make sure the
> message gets written before I close the session.
>
> PS.  Its amazing how much quicker you find a solution once you post to
the
> mailing list :P
>
> On 3/12/07, Mark Webb <[EMAIL PROTECTED]> wrote:
> >
> > 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.1branch
> > > > 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
>
>
>
>
> --
> ..Cheers
> Mark
>



--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6




--
..Cheers
Mark

Reply via email to