I learned that IO::Socket just doesn't work on Win32, so I used Socket. What I need to do next is to at least examine the win32 UDP packets in an attempt to rewrite the destination to another subnet. NetPacket::UDP doesn't give me anything to work with. I don't know where, or how many places I've gone wrong, so I'm ready for a few lessons. Here's the code I used:
Output::use warnings; use strict; use NetPacket::UDP; use NetPacket::Ethernet qw(:strip); use Socket qw(:all); use Data::Dumper $|++; # no suffering from buffering my $udp_port = 1434; socket( UDPSOCK, PF_INET, SOCK_DGRAM, getprotobyname('udp') ) or die " +socket: $!"; select( ( select(UDPSOCK), $|=1 )[0] ); # no suffering from buffering setsockopt( UDPSOCK, SOL_SOCKET, SO_REUSEADDR, 1 ) or die "setsockopt SO_REUSEADDR: $!"; setsockopt( UDPSOCK, SOL_SOCKET, SO_BROADCAST, 1 ) or die "setsockopt SO_BROADCAST: $!"; my $broadcastAddr = sockaddr_in( $udp_port, INADDR_ANY ); bind( UDPSOCK, $broadcastAddr ) or die "bind failed: $!\n"; my $input; while( my $addr = recv( UDPSOCK, $input, 1024, 0 ) ) { print "$addr => $input\n"; my $ip_obj = NetPacket::UDP::decode(NetPacket::Ethernet::eth_stri +p($addr)); my $udp_obj = NetPacket::UDP->decode($ip_obj->{data}); # my $udp_obj = NetPacket::UDP->decode($ip_obj->{data}); my $test = $ip_obj->{dest_ip}; print " $test \n"; }
☻ ♂~¼▼Å0 => ☻
Use of uninitialized value $test in concatenation (.) or string at socket2.pl line 33.
In reply to UDP Server on Win32 by mpapet
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |