udpliteclient.pl

来自「udp-lite for upd lite linux kernel」· PL 代码 · 共 29 行

PL
29
字号
#!/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;$PORTNO = 2000;      # fixed port number to connect to $cscov  = 8;         # checksum coverage (default header)die "usage: $0 <server-IP>\n" unless @ARGV;$ipaddr   = inet_aton($ARGV[0]);$portaddr = sockaddr_in($PORTNO, $ipaddr);$proto    = getprotobyname("udplite") || 136;socket(SOCKET, PF_INET, SOCK_DGRAM, $proto) or die "socket: $!";# 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: $!";while(<STDIN>) { send(SOCKET, $_, 0, $portaddr) == length($_) 	 or die "cannot send to $ipaddr#$PORTNO: $!\n";}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?