Skip to content

Commit 2b9ce2e

Browse files
mniestrojnashif
authored andcommitted
samples: sockets: echo_server: fix IPPROTO_IPV6 on UDP sockets
IPPROTO_IPV6 option was set on TCP socket (besides doing it already in tcp.c) instead of UDP. Fix that. Signed-off-by: Marcin Niestroj <[email protected]>
1 parent 346031d commit 2b9ce2e

File tree

1 file changed

+2
-2
lines changed
  • samples/net/sockets/echo_server/src

1 file changed

+2
-2
lines changed

samples/net/sockets/echo_server/src/udp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static int start_udp_proto(struct data *data, struct sockaddr *bind_addr,
8181
if (bind_addr->sa_family == AF_INET6) {
8282
/* Prefer IPv6 temporary addresses */
8383
optval = IPV6_PREFER_SRC_PUBLIC;
84-
(void)setsockopt(data->tcp.sock, IPPROTO_IPV6,
84+
(void)setsockopt(data->udp.sock, IPPROTO_IPV6,
8585
IPV6_ADDR_PREFERENCES,
8686
&optval, sizeof(optval));
8787

@@ -90,7 +90,7 @@ static int start_udp_proto(struct data *data, struct sockaddr *bind_addr,
9090
* IPv4 using another socket
9191
*/
9292
optval = 1;
93-
(void)setsockopt(data->tcp.sock, IPPROTO_IPV6, IPV6_V6ONLY,
93+
(void)setsockopt(data->udp.sock, IPPROTO_IPV6, IPV6_V6ONLY,
9494
&optval, sizeof(optval));
9595
}
9696

0 commit comments

Comments
 (0)