summaryrefslogtreecommitdiff
path: root/src/nng.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-09-20 12:11:53 -0700
committerGarrett D'Amore <garrett@damore.org>2017-09-22 12:33:50 -0700
commite236dc8141f4d00dc926fbfba7739dabf96ebcdd (patch)
tree3c88190966eac4d888008d5076e7edd1817f64a2 /src/nng.c
parentf04cfd27e2d67b0fc89b079410fc11b55b6d1979 (diff)
downloadnng-e236dc8141f4d00dc926fbfba7739dabf96ebcdd.tar.gz
nng-e236dc8141f4d00dc926fbfba7739dabf96ebcdd.tar.bz2
nng-e236dc8141f4d00dc926fbfba7739dabf96ebcdd.zip
More pipe option handling, pipe API support. Url option.
This fleshes most of the pipe API out, making it available to end user code. It also adds a URL option that is independent of the address options (which would be sockaddrs.) Also, we are now setting the pipe for req/rep. The other protocols need to have the same logic added to set the receive pipe on the message. (Pair is already done.)
Diffstat (limited to 'src/nng.c')
-rw-r--r--src/nng.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/nng.c b/src/nng.c
index ca686686..32004895 100644
--- a/src/nng.c
+++ b/src/nng.c
@@ -663,30 +663,34 @@ nng_strerror(int num)
return ("Unknown error");
}
-#if 0
int
-nng_pipe_getopt(nng_pipe *pipe, int opt, void *val, size_t *sizep)
+nng_pipe_getopt(nng_pipe id, int opt, void *val, size_t *sizep)
{
- int rv;
+ int rv;
+ nni_pipe *p;
- rv = nni_pipe_getopt(pipe, opt, val, sizep);
- if (rv == ENOTSUP) {
- // Maybe its a generic socket option.
- rv = nni_sock_getopt(pipe->p_sock, opt, val, sizep);
+ if ((rv = nni_pipe_find(&p, id)) != 0) {
+ return (rv);
}
+ rv = nni_pipe_getopt(p, opt, val, sizep);
+ nni_pipe_rele(p);
return (rv);
}
-
int
-nng_pipe_close(nng_pipe *pipe)
+nng_pipe_close(nng_pipe id)
{
- nni_pipe_close(pipe);
+ int rv;
+ nni_pipe *p;
+
+ if ((rv = nni_pipe_find(&p, id)) != 0) {
+ return (rv);
+ }
+ nni_pipe_close(p);
+ nni_pipe_rele(p);
return (0);
}
-#endif
-
// Message handling.
int
nng_msg_alloc(nng_msg **msgp, size_t size)
@@ -1012,6 +1016,7 @@ const char *nng_opt_recvfd = "recv-fd";
const char *nng_opt_sendfd = "send-fd";
const char *nng_opt_locaddr = "local-address";
const char *nng_opt_remaddr = "remote-address";
+const char *nng_opt_url = "url";
// Well known protocol options.
const char *nng_opt_req_resendtime = "req:resend-time";
const char *nng_opt_sub_subscribe = "sub:subscribe";
@@ -1034,6 +1039,7 @@ int nng_optid_recvfd;
int nng_optid_sendfd;
int nng_optid_locaddr;
int nng_optid_remaddr;
+int nng_optid_url;
int nng_optid_req_resendtime;
int nng_optid_sub_subscribe;
int nng_optid_sub_unsubscribe;