1 // SPDX-License-Identifier: GPL-2.0
10 int fd1
, fd2
, one
= 1;
11 struct sockaddr_in6 bind_addr
= {
12 .sin6_family
= AF_INET6
,
13 .sin6_port
= htons(20000),
14 .sin6_flowinfo
= htonl(0),
19 inet_pton(AF_INET6
, "::", &bind_addr
.sin6_addr
);
21 fd1
= socket(AF_INET6
, SOCK_STREAM
, IPPROTO_IP
);
23 error(1, errno
, "socket fd1");
27 if (setsockopt(fd1
, SOL_SOCKET
, SO_REUSEADDR
, &one
, sizeof(one
))) {
28 error(1, errno
, "setsockopt(SO_REUSEADDR) fd1");
32 if (bind(fd1
, (struct sockaddr
*)&bind_addr
, sizeof(bind_addr
))) {
33 error(1, errno
, "bind fd1");
38 error(1, errno
, "listen");
42 fd2
= socket(AF_INET6
, SOCK_STREAM
, IPPROTO_IP
);
44 error(1, errno
, "socket fd2");
48 if (connect(fd2
, (struct sockaddr
*)&bind_addr
, sizeof(bind_addr
))) {
49 error(1, errno
, "bind fd2");