.------[ [EMAIL PROTECTED] wrote (2003/03/04 at 08:17:01) ]------ | | Yesterday I posted a question regarding a perl script running under | xinetd on linux. I have received no responses. Perhaps | my question was unclear. I will try to rephrase my problem. | | Xinetd listens on a udp port. When it receives a datagram, it forks and | execs my perl code. | The perl code should be able to read from STDIN using <STDIN> and | retrieve the datagram content received by xinetd. | I am unable to get this to work with the perl code. | | If I write a C code program and use, | | recvfrom(0, dg, sizeof(dg), 0, &newhost, &slen) | | This will work and receive the datagram content. I have tried the perl | function recv() operating on STDIN and that does | not work either. | | Has anyone ever encountered this problem? | `-------------------------------------------------
I think this is because recv() in Perl can't be used on a file handle, only a socket which you can't get from xinetd. I was able to do it just fine with the folowing code: #!/usr/bin/perl use strict; use Sys::Syslog qw(:DEFAULT setlogsock); setlogsock('unix'); openlog('PERL-TEST', '', 'mail'); my $input = <STDIN>; syslog('info', "'$input'"); closelog(); Here was my xinetd configuration for this service: service franktest-udp { socket_type = dgram protocol = udp port = 209 wait = no user = root group = root server = /home/frank/bin/test.pl disable = no } And I used the following code to send the UDP packets ( I'm not sure if the \r is necessary or not): use IO::Socket::INET; use strict; my $sock = IO::Socket::INET->new( 'PeerAddr' => 'xxx.xxx.xxx.xxx', 'PeerPort' => '209', 'Proto' => 'udp') or die "cannot connect: $!\n"; print $sock "$ARGV[0]\r\n"; $sock->close(); I hope this helps. --------------------------------- Frank Wiles <[EMAIL PROTECTED]> http://frank.wiles.org --------------------------------- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]