Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1 use strict;
- 2 use warnings;
- 3 use IO::Socket::INET;
- 4
- 5 my $cl = IO::Socket::INET->new(
- 6 PeerAddr => '192.168.178.1:12345', # definitly rejecting
- 7 Proto => 'udp',
- 8 );
- 9 $cl->send('foo') or die "send failed: $!"; # first send will succeed
- 10 # wait some time to receive ICMP unreachable
- 11 sleep(1);
- 12 $cl->send('bar') or die "send failed: $!"; # will fail
- -------
- $ perl a.pl
- send failed: Connection refused at a.pl line 12.
- -------
- $ strace -e sendto perl a.pl
- sendto(3, "foo", 3, 0, NULL, 0) = 3
- sendto(3, "bar", 3, 0, NULL, 0) = -1 ECONNREFUSED (Connection refused)
- ------
- # tcpdump -i $if -n udp or icmp
- 18:35:43.810818 IP 192.168.178.4.54762 > 192.168.178.1.12345: UDP, length 3
- 18:35:43.812406 IP 192.168.178.1 > 192.168.178.4: ICMP 192.168.178.1 udp port 12345 unreachable, length 39
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement