diff options
| author | Garrett D'Amore <garrett@damore.org> | 2024-11-02 23:16:22 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2024-11-02 23:16:22 -0700 |
| commit | 8bac5ccdf1de7334311459b9e2666e74a2c16c15 (patch) | |
| tree | 169ce8229a1a0eb6e810685a9923be1c2bf644a6 /src/nng.c | |
| parent | d3622c0f6153ce0eccaad9c986d46b07cec91b5d (diff) | |
| download | nng-8bac5ccdf1de7334311459b9e2666e74a2c16c15.tar.gz nng-8bac5ccdf1de7334311459b9e2666e74a2c16c15.tar.bz2 nng-8bac5ccdf1de7334311459b9e2666e74a2c16c15.zip | |
Replace `NNG_OPT_PROTO`, `NNG_OPT_PROTONAME`, and friends with functions.
Socket options were a little awkward, and these are core properties
of the socket. Few if any applications need these. This also avoids
some dynamic allocations.
Diffstat (limited to 'src/nng.c')
| -rw-r--r-- | src/nng.c | 64 |
1 files changed, 64 insertions, 0 deletions
@@ -1151,6 +1151,70 @@ nng_socket_get_send_poll_fd(nng_socket id, int *fdp) } int +nng_socket_proto_id(nng_socket id, uint16_t *idp) +{ + int rv; + nni_sock *sock; + + if (((rv = nni_init()) != 0) || + ((rv = nni_sock_find(&sock, id.id)) != 0)) { + return (rv); + } + + *idp = nni_sock_proto_id(sock); + nni_sock_rele(sock); + return (0); +} + +int +nng_socket_peer_id(nng_socket id, uint16_t *idp) +{ + int rv; + nni_sock *sock; + + if (((rv = nni_init()) != 0) || + ((rv = nni_sock_find(&sock, id.id)) != 0)) { + return (rv); + } + + *idp = nni_sock_peer_id(sock); + nni_sock_rele(sock); + return (0); +} + +int +nng_socket_proto_name(nng_socket id, const char **name) +{ + int rv; + nni_sock *sock; + + if (((rv = nni_init()) != 0) || + ((rv = nni_sock_find(&sock, id.id)) != 0)) { + return (rv); + } + + *name = nni_sock_proto_name(sock); + nni_sock_rele(sock); + return (0); +} + +int +nng_socket_peer_name(nng_socket id, const char **name) +{ + int rv; + nni_sock *sock; + + if (((rv = nni_init()) != 0) || + ((rv = nni_sock_find(&sock, id.id)) != 0)) { + return (rv); + } + + *name = nni_sock_peer_name(sock); + nni_sock_rele(sock); + return (0); +} + +int nng_pipe_notify(nng_socket s, nng_pipe_ev ev, nng_pipe_cb cb, void *arg) { int rv; |
