Listening for UDP or TCP... 
Author Message
 Listening for UDP or TCP...

OK, so I have a UDP listener, using code straight out of the Cookbook:

my $sock = IO::Socket::INET->new(LocalPort => $UDP_PORT, Proto=>'udp')

my $newmsg;

while ($sock -> recv($newmsg,$MAXLEN))
{
            # Do some stuff with $newmsg;

Quote:
}

Now basically, this process that's sitting there listening for stuff is
building up a really nice convoluted hash in memory of "its view of the
world"
Now, I'd like to also listen on a TCP socket, and handle those packets
differently. That child would need to fork (or be processed) at the time the
connection opens, since the "State" is always changing (the thinking is to
allow the process to listen for messages via UDP and be able to be queried
for its state via TCP).

Is there any EASY way to do this? The cookbook mentions I could open the TCP
listener in non-blocking mode, but doesn't mention if/how this can be with
the UDP listener.

Any thoughts?

D



Wed, 08 Oct 2003 05:28:46 GMT  
 Listening for UDP or TCP...


Quote:
>OK, so I have a UDP listener[snip]
>Now basically, this process that's sitting there listening for stuff is
>building up a really nice convoluted hash in memory of "its view of the
>world"
>Now, I'd like to also listen on a TCP socket, and handle those packets
>differently. That child would need to fork (or be processed) at the time the
>connection opens, since the "State" is always changing (the thinking is to
>allow the process to listen for messages via UDP and be able to be queried
>for its state via TCP).

>Is there any EASY way to do this? The cookbook mentions I could open the TCP
>listener in non-blocking mode, but doesn't mention if/how this can be with
>the UDP listener.

>Any thoughts?

I'm thinking POE:

http://poe.perl.org/

--
Peter Scott
http://www.perldebugged.com



Thu, 09 Oct 2003 01:37:42 GMT  
 Listening for UDP or TCP...


Quote:

> I'm thinking POE:

> http://poe.perl.org/

Or Event....

http://search.cpan.org/search?dist=Event

James



Tue, 21 Oct 2003 11:02:27 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Importing Paradox table into Sidekick

2. D5 + Ora816 + LONG column

3. TDBGrid

4. Listen to a UDP using POE(perl)

5. UDP Listening server!!

6. Looking up TCP/UDP port information?

7. Perl WIN32: Looking for a TCP/UDP Connection

8. Sockets and TCP/UDP packets

9. Listening to STDIN while listening for a socket?

10. Perl 5.8 Module Win32 for Listening to Multicast UDP?

11. I've programed a Modem-Unit and I'm now looking for testers.

12. Where can I find Borland Turbo Pascal 6.0?

 

 
Powered by phpBB® Forum Software