in reply to Re: multiple socket binding
in thread multiple socket binding

Yeah, "it" would be the clients ip address, the config file is easy to load. My question is this:
for my $fh ($sel->can_read()) { if ($fh == $SERVER) { print "client connected\n"; } ... }
the $SERVER would be the bound socket, how do i test this if their are multiple sockets? I created a hash table that held all the descriptors for the bound ports, but not sure how to get it to match, i did the same as above but instead of the $fh == $SERVER, i did:
for (keys(%hash)) { if ($fh == $_) { ... } }
Thanks, 2bit4

Edit: Added <code> tags. larsen

Replies are listed 'Best First'.
Re: Re: Re: multiple socket binding
by jasonk (Parson) on Feb 23, 2003 at 22:46 UTC

    If you are adding your client sockets to the IO::Select object, then when you call can_read, it will return an array of all the socket filehandles that are ready for reading, so when you call for my $fh ($sel->can_read()) { ... }, each time through the loop, $fh will contain the filehandle for a different client connection. The hash you created with all the descriptors is unnecessarry, the IO::Select object holds them for you.

      yes i understand, but my prob is this script will bind to port 80, 110, 21, 25, etc, so i need to be able to listen on all of those ports and tell when a connection occurs and to which port