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

Steven Haigh netwiz at crc.id.au
Mon Nov 30 02:31:19 PST 2009

Hi all,

I'm wondering if anyone has a good method of using IO::Socket::INET in a
UDP proxy type environment...

I've written some (cruddy) code at the moment that listens on a UDP port
for an incoming packet. It then re-writes some details in the packet, and
then I need to send it on from the same UDP port number that we are
listening on to a different host.

Direction of traffic from client -> proxy -> server or server -> proxy ->
client can be done by inspecting the data in the packet so it isn't a huge
concern to have IO::Socket::INET have a sane way to tell traffic streams
apart, but it might be interesting (and easier) if it did.

>From my (somewhat incomplete) code at the moment, it seems that the UDP
packets are handled more like a TCP stream - in that even though I try to
set peeraddr and peerport before writing a packet to the socket, the packet
still ends up back at the client (which promptly gets confused!)

>From some extensive googling, it seems just about everything I've found
focuses on TCP streams - and my perl-foo is just not smart enough to filter
out the good stuff from the trivial example code to figure out what I need.

Any help would be appreciated!

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