Connecting to IP phone with perl/udp to read it"s logfile

Connecting to IP phone with perl/udp to read it"s logfile

am 27.09.2004 19:29:21 von Alex

Hi,

My IP Phone spits out some logfile information via UDP at port 1025. I
want to log this information using my linux box..
On the web I can find some samples of client/server perl UDP. But
this seems a little bit of both.. it connects to the phone as a client
and then must listen to it like a server.
I am a newbe at perl.. did some small programs, but nothing like
this.

I got this code so far,

#!/usr/bin/perl -w
use strict;
use IO::Socket;
my($sock, $oldmsg, $newmsg, $MAXLEN, $PORTNO, $ipaddr, $msg);
$MAXLEN = 1024;
$PORTNO = 1025;
$ipaddr = 192.168.1.20;
$sock = new IO::Socket::INET( PeerAddr => $ipaddr, PeerPort =>
$PORTNO, Proto => 'udp');
# or die "socket: $@";
print "Awaiting UDP messages on port $PORTNO\n";
while ($sock->recv($newmsg, $MAXLEN)) {
print $msg;
}

When I run it, it will give me;

[root@apeldoorn tmp]# perl test5
Awaiting UDP messages on port 1025
Can't call method "recv" on an undefined value at test5 line 11.


Anyone has any idea what I am doing wrong?

Alex van Es
SIP 495145


--
Alex@icepick.com
Icepick.com - A wired house with 9 webcams