Created
April 15, 2009 17:00
-
-
Save pmakholm/95897 to your computer and use it in GitHub Desktop.
Simple script to 'cat' an UDP port
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# quick and dirty: Read from a udp socket and print to STDOUT | |
# usage: udpcat.pl <host> <port> | |
# or: udpcat.pl <host>:<port> | |
use strict; | |
use warnings; | |
use IO::Socket::INET; | |
my $local = shift; | |
$local .= ":" . shift unless $local =~ /:/; | |
my $socket = IO::Socket::INET->new( | |
LocalAddr => $local, | |
Proto => 'udp', | |
ReuseAddr => 1, | |
) or die $!; | |
my $buffer; | |
while( defined( $socket->recv($buffer, 1024) )) { | |
print $buffer; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment