[riot-notifications] [RIOT-OS/RIOT] start a udp server that listens only to one client and port (#11894)
notifications at github.com
Tue Jul 23 17:36:49 CEST 2019
I am trying to create `udp` server with `gnrc_networking` base on [this](https://riot-os.org/api/group__net__sock__udp.html?#ga89562920ad89fe0e098fc989e3b064ec) for my samr21-xpro.
This code below works properly, but I want the UDP server to listen to only one client (ipv6 address) and its port. Therefore I have two questions:
1. Is it possible to force the server listening to only one ipv6 address and its port?
2. How can I get the client's address and port as string using `remote` variable?
sock_udp_ep_t local = SOCK_IPV6_EP_ANY;
local.port = 8080;
puts("starting udp serser at 8080");
if (sock_udp_create(&sock, &local, NULL, 0) < 0)
puts("Error creating UDP sock");
if ((res = sock_udp_recv(&sock, buf_server, sizeof(buf_server), SOCK_NO_TIMEOUT,
&remote)) >= 0)
puts("Received a message from ???); // remote ???
if ((res > 0) && (res < 99))
buf_server[res] = '\0'; /* add the null byte so buffer now holds a string */
puts((char *)buf_server); /* write this string to the display */
if (sock_udp_send(&sock, buf_server, res, &remote) < 0)
puts("Error sending reply");
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the notifications