Hi Foo: Partial reads means partial reads... If you sending whole lines at one end you;ll probably not get the whole lines all the time at the other. You have to be prepared for that.
Cheers, John > -----Original Message----- > From: Foo Ji-Haw [mailto:[EMAIL PROTECTED] > Sent: Monday, December 19, 2005 4:42 PM > To: John Serink > Cc: perl-win32-users@listserv.ActiveState.com > Subject: Re: how to detect a disconnected socket? > > > John Serink wrote: > > >Ok, if you're using sockets I strongly recommend you ALWAYS using > >sysread and syswrite as they baypass standard IO buffereing. > > > >Be careful with sysread, it cand and will return partial reads, you > >MUST be prepared for that. > > > >Unless you want your program to block on sysread, you should use > >IO::Select. Now, from Stein's nEtwork Programming with Perl, as File > >handle is ready for reading when: 1. There is at least 1 > byte of data > >in the file handle's input buffer, 2. There is an EOF on the file > >handle, the next call to sysread will return 0 in this case. With > >normal files this occurs at EOF, with sockets this occurs when the > >remote peer closes the connection, 3. There is a pending > error on the > >socket. The next sysread call will return undef and the > error will be > >in $!. > > > > > > > >So, what you are interested in is 2 or 3 or both. > > > > > Cool. Thanks for the tip John. When you mean partial reads, you don't > mean to say that any form of data corruption is taking place > right? It's > just that I will have to be responsible for putting Humpty > Dumpty (aka > the fragmented data) back together again? > > _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs