[Melbourne-pm] Handling UDP packets via IO::Socket::INET in a sane manner.

Steven Haigh netwiz at crc.id.au
Mon Nov 30 18:00:18 PST 2009

On 30/11/2009, at 11:01 PM, Daniel Pittman wrote:
> You didn't note how you were doing the packet receive and send operations;
> traditionally, I would have expect this to work with the recv and sendto calls
> as normal:
> use Socket;
> use IO::Socket::INET;
> my $s = IO::Socket::INET->new(LocalPort => 9000, Proto => 'udp') or die;
> my $buf;
> my $dst = sockaddr_in(10000, inat_aton(''));
> while (1) {
>    $buf = undef;
>    $s->recv($buf, 65535) or last;
>    $s->send($buf, undef, $dst) or die "sendto: $!";
> }

Thanks for this Daniel, I've rewritten a lot of the socket code to sometime that seems to do what I want on the UDP side now - however I'm having some issues with (what is probably the SIP packet data) getting a response from the SIP registrar. I'm not 100% sure why - as it seems that the packet out is identical apart from addresses - but it's probably something simple and stupid that I've been blind too! ;)

I've put a copy up at http://www.crc.id.au/files/sip-filter.pl in case anyone would like to have a browse and help me hack away to get something workable.

Steven Haigh

Email: netwiz at crc.id.au
Web: http://www.crc.id.au
Phone: (03) 9001 6090 - 0412 935 897

More information about the Melbourne-pm mailing list