OK. Here goes. This is going to be a LOT briefer than the full code because at this point the program itself is turning out to be a lot bigger than I anticipated. Hopefully, it will give you an idea of what I'm doing, though.
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.


In reply to Re^2: Problems with IO::Select by dirtdart
in thread Problems with IO::Select by dirtdart

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.