diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-08-17 23:57:09 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-08-18 01:57:35 -0700 |
| commit | 446b150032f24c34644f0ab91ac6ab9206250865 (patch) | |
| tree | e47b4e3812016716187201961c43b9e407a3ed50 /src/core/endpt.c | |
| parent | 76c1fc80c931b086493835d037245ebbb5f8d406 (diff) | |
| download | nng-446b150032f24c34644f0ab91ac6ab9206250865.tar.gz nng-446b150032f24c34644f0ab91ac6ab9206250865.tar.bz2 nng-446b150032f24c34644f0ab91ac6ab9206250865.zip | |
Endpoint API completely implemented.
This supports creating listeners and dialers, managing options
on them (though only a few options are supported at present),
starting them and closing them, all independently.
Diffstat (limited to 'src/core/endpt.c')
| -rw-r--r-- | src/core/endpt.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/core/endpt.c b/src/core/endpt.c index 34debc0e..f90bd068 100644 --- a/src/core/endpt.c +++ b/src/core/endpt.c @@ -418,6 +418,7 @@ nni_ep_dial(nni_ep *ep, int flags) } if ((flags & NNG_FLAG_NONBLOCK) != 0) { + ep->ep_started = 1; nni_ep_con_start(ep); nni_mtx_unlock(&ep->ep_mtx); return (0); @@ -567,6 +568,38 @@ nni_ep_pipe_remove(nni_ep *ep, nni_pipe *pipe) nni_mtx_unlock(&ep->ep_mtx); } +int +nni_ep_setopt(nni_ep *ep, int opt, const void *val, size_t sz, int check) +{ + int rv; + + if (ep->ep_ops.ep_setopt == NULL) { + return (NNG_ENOTSUP); + } + nni_mtx_lock(&ep->ep_mtx); + if (check && ep->ep_started) { + nni_mtx_unlock(&ep->ep_mtx); + return (NNG_ESTATE); + } + rv = ep->ep_ops.ep_setopt(ep->ep_data, opt, val, sz); + nni_mtx_unlock(&ep->ep_mtx); + return (rv); +} + +int +nni_ep_getopt(nni_ep *ep, int opt, void *valp, size_t *szp) +{ + int rv; + + if (ep->ep_ops.ep_getopt == NULL) { + return (NNG_ENOTSUP); + } + nni_mtx_lock(&ep->ep_mtx); + rv = ep->ep_ops.ep_getopt(ep->ep_data, opt, valp, szp); + nni_mtx_unlock(&ep->ep_mtx); + return (rv); +} + void nni_ep_list_init(nni_list *list) { |
