aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2016-12-25 11:18:27 -0800
committerGarrett D'Amore <garrett@damore.org>2016-12-25 11:18:27 -0800
commit64de60d98e8e4a896f9d13e4aa70343f329d88b4 (patch)
tree7e1ce1cf40ff6f53f518b26c87db0f93f2e8c841
parent2cf6c5b96de05ca3870495f615b23e1fcdd3c4ca (diff)
downloadnng-64de60d98e8e4a896f9d13e4aa70343f329d88b4.tar.gz
nng-64de60d98e8e4a896f9d13e4aa70343f329d88b4.tar.bz2
nng-64de60d98e8e4a896f9d13e4aa70343f329d88b4.zip
Change entry points in transports to bind() and connect().
This was done as these entry points are more clearly associated with single function transport routines like those from BSD sockets, unlike our higher level dial() and listen() APIs that do accept() or reconnect in loops.
-rw-r--r--src/core/endpt.c6
-rw-r--r--src/core/transport.h8
-rw-r--r--src/nng.c2
-rw-r--r--src/transport/inproc/inproc.c8
4 files changed, 13 insertions, 11 deletions
diff --git a/src/core/endpt.c b/src/core/endpt.c
index c5e479a2..1c5f4db5 100644
--- a/src/core/endpt.c
+++ b/src/core/endpt.c
@@ -106,12 +106,12 @@ nni_endpt_close(nni_endpt *ep)
int
-nni_endpt_listen(nni_endpt *ep)
+nni_endpt_bind(nni_endpt *ep)
{
if (ep->ep_close) {
return (NNG_ECLOSED);
}
- return (ep->ep_ops.ep_listen(ep->ep_data));
+ return (ep->ep_ops.ep_bind(ep->ep_data));
}
@@ -132,7 +132,7 @@ nni_dial_once(nni_endpt *ep)
if ((rv = nni_pipe_create(&pipe, ep->ep_ops.ep_pipe_ops)) != 0) {
return (rv);
}
- if ((rv = ep->ep_ops.ep_dial(ep->ep_data, &pipe->p_data)) != 0) {
+ if ((rv = ep->ep_ops.ep_connect(ep->ep_data, &pipe->p_data)) != 0) {
nni_pipe_destroy(pipe);
return (rv);
}
diff --git a/src/core/transport.h b/src/core/transport.h
index e4f07002..c0bade07 100644
--- a/src/core/transport.h
+++ b/src/core/transport.h
@@ -44,18 +44,18 @@ struct nni_endpt_ops {
// The endpoint will already have been closed.
void (*ep_destroy)(void *);
- // ep_dial starts dialing, and creates a new pipe,
+ // ep_connect establishes a connection, and creates a new pipe,
// which is returned in the final argument. It can return errors
// NNG_EACCESS, NNG_ECONNREFUSED, NNG_EBADADDR, NNG_ECONNFAILED,
// NNG_ETIMEDOUT, and NNG_EPROTO.
- int (*ep_dial)(void *, void **);
+ int (*ep_connect)(void *, void **);
- // ep_listen just does the bind() and listen() work,
+ // ep_bind just does the bind() and listen() work,
// reserving the address but not creating any connections.
// It should return NNG_EADDRINUSE if the address is already
// taken. It can also return NNG_EBADADDR for an unsuitable
// address, or NNG_EACCESS for permission problems.
- int (*ep_listen)(void *);
+ int (*ep_bind)(void *);
// ep_accept accepts an inbound connection, and creates
// a transport pipe, which is returned in the final argument.
diff --git a/src/nng.c b/src/nng.c
index eb08991a..8cf0d04f 100644
--- a/src/nng.c
+++ b/src/nng.c
@@ -102,6 +102,7 @@ nng_dial(nng_socket *s, const char *addr, nng_endpt **epp, int flags)
return (nni_socket_dial(s, addr, epp, flags));
}
+
int
nng_setopt(nng_socket *s, int opt, const void *val, size_t sz)
{
@@ -166,6 +167,7 @@ int
nng_pipe_getopt(nng_pipe *pipe, int opt, void *val, size_t *sizep)
{
int rv;
+
NNI_INIT_INT();
rv = nni_pipe_getopt(pipe, opt, val, sizep);
if (rv == ENOTSUP) {
diff --git a/src/transport/inproc/inproc.c b/src/transport/inproc/inproc.c
index 33598db4..0fc0a72c 100644
--- a/src/transport/inproc/inproc.c
+++ b/src/transport/inproc/inproc.c
@@ -235,7 +235,7 @@ nni_inproc_ep_close(void *arg)
static int
-nni_inproc_ep_dial(void *arg, void **pipep)
+nni_inproc_ep_connect(void *arg, void **pipep)
{
nni_inproc_ep *ep = arg;
nni_inproc_ep *srch;
@@ -281,7 +281,7 @@ nni_inproc_ep_dial(void *arg, void **pipep)
static int
-nni_inproc_ep_listen(void *arg)
+nni_inproc_ep_bind(void *arg)
{
nni_inproc_ep *ep = arg;
nni_inproc_ep *srch;
@@ -390,8 +390,8 @@ static struct nni_pipe_ops nni_inproc_pipe_ops = {
static struct nni_endpt_ops nni_inproc_ep_ops = {
.ep_create = nni_inproc_ep_create,
.ep_destroy = nni_inproc_ep_destroy,
- .ep_dial = nni_inproc_ep_dial,
- .ep_listen = nni_inproc_ep_listen,
+ .ep_connect = nni_inproc_ep_connect,
+ .ep_bind = nni_inproc_ep_bind,
.ep_accept = nni_inproc_ep_accept,
.ep_close = nni_inproc_ep_close,
.ep_pipe_ops = &nni_inproc_pipe_ops,