⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 udpliteclient.pl

📁 udp-lite for upd lite linux kernel
💻 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 + -