>Peter Scott wrote:
>
> > At 10:13 AM 7/6/01 -0400, Stephen LeClaire wrote:
> > >I have a client server configured using the inetd daemon to call the
> > >server software.  Most of the time, the server grabs all of the data
> > >sent by the client, but sometimes the server only grabs a portion of the
> > >data.  I have verified, using snoop, that all the data from the client
> > >makes it to the server.
> > >
> > >The server script simply reads the standard input:  "$msg = <STDIN>".  I
> > >tried doing a "while ($msg = <STDIN>)"  but it just causes things to
> > >hang.   Any ideas and insights are greatly appreciated.
> >
> > Depends on what your protocol is.  The server will read up until the first
> > newline with your current approach.  With your attempted approach it will
> > read until the socket is closed by the client, which I gather it isn't.  So
> > you need to define your protocol so that the server can know when the
> > client has finished sending (that, or fork separate reading/writing
> > processes, or use select with a timeout).
>
>Peter,
>
>Thanks for the input.  I failed to mention that the protocol is tcp.

No, I assumed that; I meant, the format of the acceptable transmissions and 
replies.  That's something you decide.

>  The
>first newline is what bothers me.  I send a newline at the end of the string
>and the string does not contain a newline.  I can send the same string
>repeatably with success but it will eventually fail.  Again, any further input
>is greatly appreciated.

Could be some kind of synchronization problem, hard to debug.  Lincoln 
Stein's Network Programming with Perl book is excellent for what you're 
doing.  You might also see if Net::Server does anything for you 
(http://search.cpan.org/search?dist=Net-Server).

--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com

Reply via email to