Send and recv with plain buffer as an argument added

Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
This commit is contained in:
Martin Sustrik 2011-09-14 12:21:11 +02:00
parent f5bc62f8c3
commit ac1ba21f13

20
zmq.hpp
View File

@ -264,6 +264,16 @@ namespace zmq
throw error_t ();
}
inline size_t send (const void *buf_, size_t len_, int flags_ = 0)
{
int nbytes = zmq_send (ptr, buf_, len_, flags_);
if (nbytes >= 0)
return (size_t) nbytes;
if (zmq_errno () == EAGAIN)
return 0;
throw error_t ();
}
inline bool send (message_t &msg_, int flags_ = 0)
{
int nbytes = zmq_sendmsg (ptr, &(msg_.msg), flags_);
@ -274,6 +284,16 @@ namespace zmq
throw error_t ();
}
inline size_t recv (void *buf_, size_t len_, int flags_ = 0)
{
int nbytes = zmq_recv (ptr, buf_, len_, flags_);
if (nbytes >= 0)
return (size_t) nbytes;
if (zmq_errno () == EAGAIN)
return 0;
throw error_t ();
}
inline bool recv (message_t *msg_, int flags_ = 0)
{
int nbytes = zmq_recvmsg (ptr, &(msg_->msg), flags_);