Created
June 3, 2014 05:44
-
-
Save jesboat/96bb14a12b2e24dbd997 to your computer and use it in GitHub Desktop.
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 | |
use strict; | |
use warnings; | |
use Errno; | |
use IO::Socket::INET; | |
my $sock = IO::Socket::INET->new( | |
LocalPort => 6666, | |
ReuseAddr => 1, | |
ReusePort => 1, | |
Proto => "udp", | |
) | |
or die "socket: $!\n"; | |
$| = 1; | |
my $quit; | |
$SIG{TERM} = sub { $quit = 1 }; | |
while (not $quit) { | |
my $buf = ""; | |
my $peer = recv($sock, $buf, 1024 * 1024, 0); | |
if (not $peer) { | |
die "recv: $!\n" unless $!{EINTR} or $!{EAGAIN}; | |
} | |
print $buf; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Because BSD netcat sucks and socat keeps segfaulting.