$SIG{IO} example
From: Sébastien Cottalorda (sppNOSPAM_at_monaco377.com)
Date: 11/29/04
- Next message: Thomas Kratz: "Re: Win32API::Registry, RegOpenKeyEx fails [The parameter is incorrect]"
- Previous message: John W. Krahn: "Re: hashing function"
- Next in thread: Anno Siegel: "Re: $SIG{IO} example"
- Reply: Anno Siegel: "Re: $SIG{IO} example"
- Reply: Scott W Gifford: "Re: $SIG{IO} example"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 ]
- Next message: Thomas Kratz: "Re: Win32API::Registry, RegOpenKeyEx fails [The parameter is incorrect]"
- Previous message: John W. Krahn: "Re: hashing function"
- Next in thread: Anno Siegel: "Re: $SIG{IO} example"
- Reply: Anno Siegel: "Re: $SIG{IO} example"
- Reply: Scott W Gifford: "Re: $SIG{IO} example"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|