From 603282f28e6f2e1b32d3a587d8de761f9f94ad45 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 2 Jun 2024 23:33:27 -0700 Subject: UDP: Introduce an experimental (undocumented for now) public API for UDP. (#1838) This exposes the UDP methods as nng_ methods, and adds support for Multicast Membership, which is useful in a variety of situations. No documentation is provided, and applications should consider thios API experimental. --- src/nng.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/nng.c') diff --git a/src/nng.c b/src/nng.c index 474f07b1..e9574626 100644 --- a/src/nng.c +++ b/src/nng.c @@ -10,6 +10,7 @@ #include "nng/nng.h" #include "core/nng_impl.h" +#include "core/platform.h" // This file provides the "public" API. This is a thin wrapper around // internal API functions. We use the public prefix instead of internal, @@ -2174,3 +2175,41 @@ nng_socket_pair(int fds[2]) { return (nni_socket_pair(fds)); } + +int +nng_udp_open(nng_udp **udp, nng_sockaddr *sa) +{ + (void) nni_init(); + return (nni_plat_udp_open((nni_plat_udp **) udp, sa)); +} + +void +nng_udp_close(nng_udp *udp) +{ + nni_plat_udp_close((nni_plat_udp *) udp); +} + +int +nng_udp_sockname(nng_udp *udp, nng_sockaddr *sa) +{ + return (nni_plat_udp_sockname((nni_plat_udp *) udp, sa)); +} + +void +nng_udp_send(nng_udp *udp, nng_aio *aio) +{ + nni_plat_udp_send((nni_plat_udp *) udp, aio); +} + +void +nng_udp_recv(nng_udp *udp, nng_aio *aio) +{ + nni_plat_udp_recv((nni_plat_udp *) udp, aio); +} + +int +nng_udp_multicast_membership(nng_udp *udp, nng_sockaddr *sa, bool join) +{ + return ( + nni_plat_udp_multicast_membership((nni_plat_udp *) udp, sa, join)); +} -- cgit v1.2.3-70-g09d2