$SIG{IO} example

From: Sébastien Cottalorda (sppNOSPAM_at_monaco377.com)
Date: 11/29/04


Date: Mon, 29 Nov 2004 11:31:23 +0100

Hi all,

I'm planning to make a script that, on socket reception, do reception, but
the rest of time do something else.

#======================================================================
#!/usr/bin/perl -w
use IO::Select;
use IO::Socket;
unless ($socket = IO::Socket::INET->new(PeerAddr=> $adr_ip,
                                        PeerPort=> $port,
                                        Proto=> "tcp",
                                        Timeout=>10,
                                        Type=> SOCK_STREAM)){
            die "Unable to create a tcp server $!";
}
$s->add($socket);
$SIG{IO}=\$do_reception;
while(1) {
        #
        # do something ...
        # even sending datas throught the socket
        #
}

sub do_reception{
        if ($s->can_read(10)){
            &logmsg("Reception ...\n");
            if (defined $socket->recv($data_work,1024,0)){
                print "< $data_work\n";
            }
            else {
                print "Unable to receive\n";
            }
        }
        else {
            print "Timeout Receiving\n";
        }
}

I've made that but it doesn't seem to work.
Do you have a SIG{IO} exemple program

Thanks in advance for any kind of help.

Sébastien Cottalorda

-- 
[ retirer NOSPAM pour répondre directement
 remove NOSPAM to reply directly ]


Relevant Pages

  • Re: $SIG{IO} example
    ... Anno Siegel wrote: ... >> I'm planning to make a script that, on socket reception, do reception, ... -- [retirer NOSPAM pour répondre directement remove NOSPAM to reply directly] ...
    (comp.lang.perl.misc)
  • Re: Protecting passwords in Perl scripts?
    ... > must be readable by the effective uid of the script). ... [retirer NOSPAM pour répondre directement ...
    (comp.lang.perl.misc)
  • Re: $SIG{IO} example
    ... Sébastien Cottalorda wrote in comp.lang.perl.misc: ... > I'm planning to make a script that, on socket reception, do reception, but ...
    (comp.lang.perl.misc)