Click here to get back home

IO::Socket::INET nonblocking confusing

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
IO::Socket::INET nonblocking confusing DGG 04-25-2007
Posted by DGG on April 25, 2007, 7:27 am
Please log in for more thread options


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?


Posted by xhoster on April 25, 2007, 4:58 pm
Please log in for more thread options


> 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

Similar ThreadsPosted
IO::Socket::SSL March 24, 2005, 10:10 pm
LWP and socket May 1, 2007, 6:06 pm
IO::Socket sometimes hang, why? Please help November 7, 2004, 7:54 pm
IO::Socket->socketpair() May 21, 2007, 3:25 pm
Installing IO::Socket::SSL on Win32? June 30, 2006, 11:11 am
IO::Socket default timeout September 25, 2006, 2:35 pm
IO::Socket::SSL: cannot connect using different LocalAddr October 2, 2007, 12:28 pm
Credentials and POST method with IO::Socket::SSL? June 30, 2006, 5:14 pm
SSLeay & OpenSSL problem with install of IO::Socket::SSL June 24, 2005, 9:39 am
IPV6 socket connection, with a link-local address January 11, 2008, 1:12 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap