diff options
| author | Garrett D'Amore <garrett@damore.org> | 2025-04-14 00:03:47 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2025-04-19 20:42:59 -0700 |
| commit | df3059dd130ce22f2326abeb41149bdf35e0c38d (patch) | |
| tree | 83ce0a27ac4a29f058977e378cc9f321e5995ef7 /include | |
| parent | 55925438bc8b8fd243ab995c48c8996ac49a6652 (diff) | |
| download | nng-gdamore/udpconn.tar.gz nng-gdamore/udpconn.tar.bz2 nng-gdamore/udpconn.zip | |
UDP: Add support for connected mode UDP sockets.gdamore/udpconn
Diffstat (limited to 'include')
| -rw-r--r-- | include/nng/nng.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/nng/nng.h b/include/nng/nng.h index b3c5ae14..2c95d8f1 100644 --- a/include/nng/nng.h +++ b/include/nng/nng.h @@ -159,6 +159,7 @@ typedef enum { NNG_EPEERAUTH = 27, NNG_EBADTYPE = 30, NNG_ECONNSHUT = 31, + NNG_ENOTCONN = 32, NNG_ESTOPPED = 999, NNG_EINTERNAL = 1000, NNG_ESYSERR = 0x10000000, @@ -1223,6 +1224,13 @@ typedef struct nng_udp nng_udp; // to the specified address. NNG_DECL int nng_udp_open(nng_udp **udpp, nng_sockaddr *sa); +// nng_udp_connect initializes a ocnnected UDP socket, if the peer +// address is not NULL. If the peer address is NULL, then the socket +// is opened with only BIND, but with SO_REUSEADDR set to be compatible +// with connected sockets on the same local address. +NNG_DECL int nng_udp_connect( + nng_udp **udpp, nng_sockaddr *self, nng_sockaddr *peer); + // nng_udp_close closes the underlying UDP socket. NNG_DECL void nng_udp_close(nng_udp *udp); @@ -1230,6 +1238,11 @@ NNG_DECL void nng_udp_close(nng_udp *udp); // This is useful to determine a chosen port after binding to port 0. NNG_DECL int nng_udp_sockname(nng_udp *udp, nng_sockaddr *sa); +// nng_udp_peername determines the peer address for a connected UDP socket. +// It fails with NNG_ENOTCONN if the socket is was not created with +// `nng_udp_connect`. +NNG_DECL int nng_udp_peername(nng_udp *udp, nng_sockaddr *sa); + // nng_udp_send sends the data in the aio to the the // destination specified in the nng_aio. The iovs are the UDP payload. // The destination address is the first input (0th) for the aio. |
