----- Original Message -----
From: "Foo Ji-Haw" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Monday, October 31, 2005 7:19 PM
Subject: Reading from a buffer in a IO::Socket::INET
> Hello all,
>
> I am trying to read from a socket connection, a text string if any.
> Problem is, the text string does not end with a CR. Socket connection is
> ok. Below is my code snippet:
> ...
> my $buffer;
> $sock->blocking(0);
> while (my $count = $sock->read($buffer,512))
> {
> print "$buffer";
> }
>
> The result is that the code hangs forever. Nothing is printed. Is there
> any way for me to read the socket buffer without blocking, or is my code
> missing something?
>
It may simply be that you need to set $| = 1. I find that without that (even
though the socket is autoflushed) $buffer is not autoflushed.
I'm also not very familiar with both read() and non-blocking sockets. I find
trouble when I try to do a read() on $sock, but it works ok if I code it
as:
$| = 1;
my $client = $sock->accept();
my $count = $client->read($buffer, 512);
print "$buffer";
Other than that, I would probably need to see a complete script (bare
minimum server script that exhibits the problem).
Cheers,
Rob
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs