Re: Sockets

[email protected] (( Marc) (A.) (Lehmann ))
Newsgroups perl.loop
Message-ID <[email protected]>
On Thu, Jul 26, 2001 at 10:03:05AM -0400, Jeff Boes <[email protected]> wrote:
> Are there any "gotchas" with respect to 'io' events and sockets?

What you posted seems to work fine here (Linux-2.4, Event-0.83), so I
suspect something goes wrong with your socket setup. Without an example
script (what you posted was incomplete) it is difficult to tell, though.

I used:

   use Event;
   use IO::Socket::INET;

    $watch_in = IO::Socket::INET->new(               
                                      Proto => 'udp',
                                      LocalPort => 1234,
                                      ReuseAddr => 1,               
                                     )               
      or die;
    $events{watchdog} = Event->io(
                                  cb => sub { print "new connection\n" },
                                  fd => $watch_in,
                                  poll => 'r',    
                                 );           
   Event::loop;

and doing "echo hi | ttcp -t -u -p 1234 localhost" gave me an endless loop
of "new connection" messages, just as expected.

-- 
      -----==-                                             |
      ----==-- _                                           |
      ---==---(_)__  __ ____  __       Marc Lehmann      +--
      --==---/ / _ \/ // /\ \/ /       [email protected]      |e|
      -=====/_/_//_/\_,_/ /_/\_\       XX11-RIPE         --+
    The choice of a GNU generation                       |
                                                         |
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.