aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2016-12-14 08:22:23 -0800
committerGarrett D'Amore <garrett@damore.org>2016-12-14 08:22:23 -0800
commit75aee14e2951cfbd4d8d22375a9f4301890da1ee (patch)
tree010ddee91e0001453a5b72ed8905ce4e10e91de5
parent0f8b89d497d7d8bb0386d816c2a18fe7084153b4 (diff)
downloadnng-75aee14e2951cfbd4d8d22375a9f4301890da1ee.tar.gz
nng-75aee14e2951cfbd4d8d22375a9f4301890da1ee.tar.bz2
nng-75aee14e2951cfbd4d8d22375a9f4301890da1ee.zip
Protocols are 16-bit.
-rw-r--r--src/core/socket.c8
-rw-r--r--src/nng.h8
2 files changed, 14 insertions, 2 deletions
diff --git a/src/core/socket.c b/src/core/socket.c
index ee436bb2..9c289a94 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -59,7 +59,7 @@ nni_socket_recvq(nng_socket_t s)
}
int
-nng_socket_create(nng_socket_t *sockp, int proto)
+nng_socket_create(nng_socket_t *sockp, uint16_t proto)
{
return (NNG_EAGAIN); /* XXX: IMPLEMENT ME */
}
@@ -125,3 +125,9 @@ nng_socket_sendmsg(nng_socket_t sock, nng_msg_t msg, int tmout)
}
return (rv);
}
+
+uint16_t
+nng_socket_protocol(nng_socket_t sock)
+{
+ return (sock->s_ops.proto_self);
+}
diff --git a/src/nng.h b/src/nng.h
index 0adadb39..556ffba3 100644
--- a/src/nng.h
+++ b/src/nng.h
@@ -67,7 +67,7 @@ typedef struct nng_stat *nng_stat_t;
* error code on failure, or zero on success. The socket starts in cooked
* mode.
*/
-NNG_DECL int nng_socket_create(nng_socket_t *, int proto);
+NNG_DECL int nng_socket_create(nng_socket_t *, uint16_t proto);
/*
* nng_socket_close closes the socket, terminating all activity and
@@ -80,6 +80,12 @@ NNG_DECL int nng_socket_create(nng_socket_t *, int proto);
NNG_DECL int nng_socket_close(nng_socket_t);
/*
+ * nng_socket_protocol returns the protocol number the socket was created
+ * with.
+ */
+uint16_t nng_socket_protocol(nng_socket_t);
+
+/*
* nng_socket_setopt sets an option for a specific socket.
*/
NNG_DECL int nng_socket_setopt(nng_socket_t, int, void *, size_t);