5 #include <sys/socket.h>
8 #include <netinet/in.h>
11 #define PACKET_SIZE 1200
14 int main(int argc, char **argv)
16 int sock = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
17 struct sockaddr_in6 addr;
18 addr.sin6_family = AF_INET6;
19 addr.sin6_port = htons(atoi(argv[2]));
21 inet_pton(AF_INET6, argv[1], &addr.sin6_addr);
23 bind(sock, (struct sockaddr *)&addr, sizeof(addr));
27 static char buf[PACKET_SIZE];
29 ssize_t len = recv(sock, buf, PACKET_SIZE, 0);
34 if (len < sizeof(int)) {
35 fprintf(stderr, "short packet\n");
38 memcpy(&seqno, buf, sizeof(int));
39 printf("%d\n", seqno);