?? udpliteclient.pl
字號:
#!/usr/bin/perl# A simple Perl UDP-Lite client which connects to the IP address given# on the commandline, using the fixed port `$PORTNO'. # Terminate via CTRL-D.use Socket;use Socket6;$PORTNO = 2000; # fixed port number to connect to $cscov = 8; # checksum coverage (default header)$proto = getprotobyname("udplite") || 136;die "usage: $0 <server-IP>\n" unless @ARGV;# 1. resolve address@res = getaddrinfo($ARGV[0], "$PORTNO", AF_UNSPEC, SOCK_DGRAM);$family = -1;while (scalar(@res) >= 5) { ($family, $socktype, $proto2, $saddr, $canonname, @res) = @res; ($host, $port) = getnameinfo($saddr, NI_NUMERICHOST | NI_NUMERICSERV); print STDERR "Connecting to $host on port $port.\n"; socket(SOCKET, $family, $socktype, $proto) || next; connect(SOCKET, $saddr) && last; close(SOCKET); $family = -1;}die "connect attempt failed\n" if $family == -1;# 2. set socket options# since it is unlikely that the Perl module has translated# /usr/include/netinet/udplite.h, we use the corresponding numbers#define UDPLITE_SEND_CSCOV 10 /* Actual coverage length */#define UDPLITE_RECV_CSCOV 11 /* Minimum acceptable coverage */setsockopt(SOCKET, $proto, 10, $cscov) or die "setsockopt: $!";# 3. send until EOFwhile(<STDIN>) { send(SOCKET, $_, 0, $saddr) == length($_) or die "cannot send to $ipaddr#$PORTNO: $!\n";}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -