IO::Socket::INET nonblocking confusing
am 25.04.2007 13:27:48 von DGG
I am confused with the IO::Socket module
When I attempt to open a "blocking" udp socket with the following
lines:
my $sock = new IO::Socket::INET(
PeerAddr => $addr,
PeerPort => $port,
Proto => 'udp',
Blocking => 1);
$sock or die "no socket :$!, $@\n";
It returns "no socket:......"
If I remove the "Blocking => 1" option, the socket is created
successfully. Anyone knows how to enable the "Blocking" option
gracefully?
Calling the following line afterwards:
$len = $sock->recv( my $reply, 128);
As it is said that the default socket will be a "blocking" one, I
expect it to wait until there is new data. However, it returns
immediately, with an undefined $len.
Is it the normal behavior?
Re: IO::Socket::INET nonblocking confusing
am 25.04.2007 22:58:45 von xhoster
DGG wrote:
> I am confused with the IO::Socket module
>
> When I attempt to open a "blocking" udp socket with the following
> lines:
>
> my $sock = new IO::Socket::INET(
> PeerAddr => $addr,
> PeerPort => $port,
> Proto => 'udp',
> Blocking => 1);
> $sock or die "no socket :$!, $@\n";
>
> It returns "no socket:......"
Complete with the ellipsis? If not, what is the actual error message you
get?
What is your OS and version of IO::Socket and IO::Socket::INET?
> If I remove the "Blocking => 1" option, the socket is created
> successfully. Anyone knows how to enable the "Blocking" option
> gracefully?
>
> Calling the following line afterwards:
> $len = $sock->recv( my $reply, 128);
>
> As it is said that the default socket will be a "blocking" one, I
> expect it to wait until there is new data. However, it returns
> immediately, with an undefined $len.
What is in "$!" after recv returns?
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB