in reply to stream info from udp stream on port xx and dump it into syslog

Search CPAN for IO::Socket and Syslog.

Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')

Don't fool yourself.
  • Comment on Re: stream info from udp stream on port xx and dump it into syslog

Replies are listed 'Best First'.
Re^2: stream info from udp stream on port xx and dump it into syslog
by bengmau (Beadle) on Jun 09, 2005 at 21:22 UTC
    ok looks like I need to use IO::Socket::Inet here's the sample code from cpan
    $sock = IO::Socket::INET->new(PeerAddr => 'www.perl.org', PeerPort => 'http(80)', Proto => 'tcp'); $sock = IO::Socket::INET->new(PeerAddr => 'localhost:smtp(25)'); $sock = IO::Socket::INET->new(Listen => 5, LocalAddr => 'localhost', LocalPort => 9000, Proto => 'tcp'); $sock = IO::Socket::INET->new('127.0.0.1:25'); $sock = IO::Socket::INET->new(PeerPort => 9999, PeerAddr => inet_ntoa(INADDR_BROADCA +ST), Proto => udp, LocalAddr => 'localhost', Broadcast => 1 ) or die "Can't bind : $@\n";
    I want to create a listening daemon on port 6969 on any IP device for example and stream the info into a file for now. I can deal with the syslog forwarding. Which of the example sets should I use? I'm a little confused on which I should use I think it should be:
    $sock = IO::Socket::INET->new(Listen => 5, LocalAddr => 'localhost', LocalPort => 6969, Proto => 'udp');
    someone give me a little example code of what I should do? Thanks
      UDP doesn't have the "listen" concept, it's a pure datagram service. Try this out:
      #!/usr/bin/perl use strict; use warnings; use IO::Socket::INET; my $sock = IO::Socket::INET->new(Proto => 'udp', LocalPort => 12000); while (<$sock>) { print "Received: $_"; }
      Just don't be afraid to try - and to post your attempts. Many here appreciate some effort from the OP side, me included.

      Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')

      Don't fool yourself.