This just got odder.  Looks like I'm reading the data in just fine, but it
won't print to the screen unless I preface and suffix it with a newline.
Any idea what could cause that?

Robert Aspinall
Support Engineer
V-ONE Corporation
[EMAIL PROTECTED]



> You might consider the following.  I am translating from C some code
> from W. Richard Stevens' "Unix Network Programming", which I think it
> an essential read for anyone who wants to do socket programming:
>
>
> use strict;
> use IO::Socket::INET;
>
> my $socket = new IO::Socket::INET(PeerAddr => 'foo.com',
>   PeerPort => 'telnet',
>   Proto => 'tcp',
>   Type => 'SOCK_STREAM'
> );
> my $buf;
> my $bufsize = 8192;
>
> while( ($n = read($socket, $buf, $bufsize) > 0) {
> print $buf;
> }
> if($n < 1) die "read() error: $1";
>
> This code is untested, but it should get the main point across.  If
> you have any problems with it, feel free to let me know,
>
> Good luck,
>
> C.J.
>
> On Fri, 6 Jul 2001, Robert Aspinall wrote:
>
> > Hello,
> >
> > I'm new to the perl beginners list, as of about 5 minutes ago.  I'm
having
> > problems reading
> > info from a socket.  Entire lines (suffixed with a newline character)
come
> > through fine, but anytime
> > the server sends a few characters without a newline, I don't recieve it.
I
> > can read these characters
> > manually with $socket->recv($buffer, $length), but I'm not sure how to
> > actually code a while loop
> > to depend on this, something akin to "as long as there are characters,
> > recieve them, when there aren't any, wait for more.)
> >
> > Any ideas?
> >


Reply via email to