in reply to Re: Problems with IO::Select
in thread Problems with IO::Select
use strict; use IO::Socket; use IO::Select; #Just opens the configuration file and stuffs all the values into the +%config hash my %config = get_config($ARGV[0] ? $ARGV[0] : "/etc/MailScanManager/Ma +ilScanManager.conf"); my $sel = new IO::Select; #$config{connections} is an array of hashes containing information abo +ut each listening socket #the server should create foreach my $connection (@{$config{connections}}) { if($connection->{socket_type} & IP_SOCKET) { if(!$connection->{socket_address}) { $connection->{socket_addr +ess} = INADDR_ANY; } if(!$connection->{socket_port}) { $connection->{socket_port} = + 7000; } $connection->{socket} = new IO::Socket::INET(Listen => 1, Loca +lPort => $connection->{socket_port}, LocalAddr => $connection->{socke +t_address}) || die("Could not create socket $!");; $sel->add($connection->{socket}); } if($connection->{socket_type} & UNIX_SOCKET) { if(!$connection->{address}) { $connection->{address} = "/var/r +un/MailScanManager/msm.sock"; } unlink($connection->{address}); $connection->{socket} = new IO::Socket::UNIX(Type => SOCK_STRE +AM, Listen => 5, Local => $connection->{address}) || die("Could not c +reate socket $!"); chmod 777, $connection->{address}; $sel->add($connection->{socket}); } } while(my @ready = $sel->can_read) { foreach my $fh (@ready) { #Determine if it's a connection attempt or data sent by a client and a +ct appropriately } }
I have run this code using TCP/IP sockets and it works perfectly. Select sits and waits for one of the sockets to be readable and then reacts correctly. It only seems to act up when I'm using it with a Unix socket. I haven't tried a combination of the two. I also haven't tried a different path for the Unix socket, but as I stated earlier, it's getting created and the permissions on the directory and file are set to 777, so I don't think that's the problem.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Problems with IO::Select
by ikegami (Patriarch) on Jul 02, 2006 at 20:49 UTC | |
by dirtdart (Beadle) on Jul 02, 2006 at 21:22 UTC | |
by ikegami (Patriarch) on Jul 02, 2006 at 22:33 UTC | |
by dirtdart (Beadle) on Jul 02, 2006 at 23:45 UTC |