diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/socket.c | 4 | ||||
| -rw-r--r-- | src/core/socket.h | 1 | ||||
| -rw-r--r-- | src/nng.c | 16 | ||||
| -rw-r--r-- | src/nng.h | 6 |
4 files changed, 24 insertions, 3 deletions
diff --git a/src/core/socket.c b/src/core/socket.c index 99573a2f..e3298886 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -57,8 +57,8 @@ nni_socket_create(nni_socket **sockp, uint16_t proto) NNI_LIST_INIT(&sock->s_pipes, nni_pipe, p_sock_node); NNI_LIST_INIT(&sock->s_eps, nni_endpt, ep_sock_node); - if (((rv = nni_msgqueue_create(&sock->s_uwq, 1)) != 0) || - ((rv = nni_msgqueue_create(&sock->s_urq, 1)) != 0)) { + if (((rv = nni_msgqueue_create(&sock->s_uwq, 0)) != 0) || + ((rv = nni_msgqueue_create(&sock->s_urq, 0)) != 0)) { goto fail; } diff --git a/src/core/socket.h b/src/core/socket.h index 1376c454..4fa59355 100644 --- a/src/core/socket.h +++ b/src/core/socket.h @@ -45,5 +45,6 @@ extern void nni_socket_rem_pipe(nni_socket *, nni_pipe *); extern uint16_t nni_socket_proto(nni_socket *); extern int nni_socket_setopt(nni_socket *, int, const void *, size_t); extern int nni_socket_getopt(nni_socket *, int, void *, size_t *); +extern int nni_socket_recvmsg(nni_socket *, nni_msg **, int); #endif // CORE_SOCKET_H @@ -48,6 +48,22 @@ nng_socket_protocol(nng_socket *s) return (nni_socket_proto(s)); } +int +nng_recvmsg(nng_socket *s, nng_msg **msgp, int flags) +{ + int rv; + nni_duration expire; + if ((rv = nni_init()) != 0) { + return (rv); + } + if (flags == NNG_FLAG_NONBLOCK) { + expire = 0; + } else { + // XXX: revise this timeout from socket option!! + expire = 1000000; + } + return (nni_socket_recvmsg(s, msgp, expire)); +} // Misc. const char * @@ -193,6 +193,10 @@ NNG_DECL int nng_msg_trunc_header(nng_msg *, size_t); NNG_DECL int nng_pipe_getopt(nng_pipe *, int, void *, size_t *); NNG_DECL int nng_pipe_close(nng_pipe *); +// Flags. +#define NNG_FLAG_ALLOC 1 // Recv to allocate receive buffer. +#define NNG_FLAG_NONBLOCK 2 // Non-block send/recv. + // Protocol numbers. These are to be used with nng_socket_create(). // These values are used on the wire, so must not be changed. The major // number of the protocol is shifted left by 4 bits, and a subprotocol is @@ -349,7 +353,7 @@ NNG_DECL int nng_device(nng_socket *, nng_socket *); // Default linger time in microseconds. The framework will wait up until // this long for outgoing message queues to drain before closing underlying // connections, when closing the socket itself. -#define NNG_LINGER_DEFAULT (1000000) +#define NNG_LINGER_DEFAULT (1000000) #ifdef __cplusplus } |
