Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
a908ccbf
Commit
a908ccbf
authored
Feb 13, 2012
by
Pieter Hintjens
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #241 from skaller/master
provide type safe sockets and contexts
parents
48423c9e
48079356
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
16 deletions
+45
-16
zmq.h
include/zmq.h
+43
-16
zmq.cpp
src/zmq.cpp
+2
-0
No files found.
include/zmq.h
View file @
a908ccbf
...
...
@@ -64,6 +64,33 @@ extern "C" {
#define ZMQ_VERSION \
ZMQ_MAKE_VERSION(ZMQ_VERSION_MAJOR, ZMQ_VERSION_MINOR, ZMQ_VERSION_PATCH)
/* ensure one of ZMQ_TYPE_SAFE/UNSAFE is defined */
/* Choose default based on version */
/* Uncomment to test */
/* #define ZMQ_EMULATE_TYPE_SAFE */
#if !defined(ZMQ_TYPE_SAFE) && !defined(ZMQ_TYPE_UNSAFE)
# if ZMQ_VERSION_MAJOR <= 3
# if defined ZMQ_EMULATE_TYPE_SAFE
# else
# define ZMQ_TYPE_UNSAFE
# endif
# else
# define ZMQ_TYPE_SAFE
# endif
#elif defined(ZMQ_TYPE_SAFE) && defined(ZMQ_TYPE_UNSAFE)
# error "BOTH ZMQ_TYPE_SAFE and ZMQ_TYPE_UNSAFE are defined!"
#endif
#ifdef ZMQ_TYPE_UNSAFE
typedef
void
*
zmq_socket_t
;
typedef
void
*
zmq_ctx_t
;
#else
typedef
struct
zmq_socket_t
{
void
*
data
;
}
zmq_socket_t
;
typedef
struct
zmq_ctx_t
{
void
*
data
;
}
zmq_ctx_t
;
#endif
/* Run-time API version detection */
ZMQ_EXPORT
void
zmq_version
(
int
*
major
,
int
*
minor
,
int
*
patch
);
...
...
@@ -146,9 +173,9 @@ ZMQ_EXPORT int zmq_getmsgopt (zmq_msg_t *msg, int option, void *optval,
/* 0MQ infrastructure (a.k.a. context) initialisation & termination. */
/******************************************************************************/
ZMQ_EXPORT
void
*
zmq_init
(
int
io_threads
);
ZMQ_EXPORT
void
*
zmq_init_thread_safe
(
int
io_threads
);
ZMQ_EXPORT
int
zmq_term
(
void
*
context
);
ZMQ_EXPORT
zmq_ctx_t
zmq_init
(
int
io_threads
);
ZMQ_EXPORT
zmq_ctx_t
zmq_init_thread_safe
(
int
io_threads
);
ZMQ_EXPORT
int
zmq_term
(
zmq_ctx_t
context
);
/******************************************************************************/
/* 0MQ socket definition. */
...
...
@@ -202,21 +229,21 @@ ZMQ_EXPORT int zmq_term (void *context);
#define ZMQ_DONTWAIT 1
#define ZMQ_SNDMORE 2
ZMQ_EXPORT
void
*
zmq_socket
(
void
*
context
,
int
type
);
ZMQ_EXPORT
int
zmq_close
(
void
*
s
);
ZMQ_EXPORT
int
zmq_setsockopt
(
void
*
s
,
int
option
,
const
void
*
optval
,
ZMQ_EXPORT
zmq_socket_t
zmq_socket
(
zmq_ctx_t
context
,
int
type
);
ZMQ_EXPORT
int
zmq_close
(
zmq_socket_t
s
);
ZMQ_EXPORT
int
zmq_setsockopt
(
zmq_socket_t
s
,
int
option
,
const
void
*
optval
,
size_t
optvallen
);
ZMQ_EXPORT
int
zmq_getsockopt
(
void
*
s
,
int
option
,
void
*
optval
,
ZMQ_EXPORT
int
zmq_getsockopt
(
zmq_socket_t
s
,
int
option
,
void
*
optval
,
size_t
*
optvallen
);
ZMQ_EXPORT
int
zmq_bind
(
void
*
s
,
const
char
*
addr
);
ZMQ_EXPORT
int
zmq_connect
(
void
*
s
,
const
char
*
addr
);
ZMQ_EXPORT
int
zmq_send
(
void
*
s
,
const
void
*
buf
,
size_t
len
,
int
flags
);
ZMQ_EXPORT
int
zmq_recv
(
void
*
s
,
void
*
buf
,
size_t
len
,
int
flags
);
ZMQ_EXPORT
int
zmq_sendmsg
(
void
*
s
,
zmq_msg_t
*
msg
,
int
flags
);
ZMQ_EXPORT
int
zmq_recvmsg
(
void
*
s
,
zmq_msg_t
*
msg
,
int
flags
);
ZMQ_EXPORT
int
zmq_bind
(
zmq_socket_t
s
,
const
char
*
addr
);
ZMQ_EXPORT
int
zmq_connect
(
zmq_socket_t
s
,
const
char
*
addr
);
ZMQ_EXPORT
int
zmq_send
(
zmq_socket_t
s
,
const
void
*
buf
,
size_t
len
,
int
flags
);
ZMQ_EXPORT
int
zmq_recv
(
zmq_socket_t
s
,
void
*
buf
,
size_t
len
,
int
flags
);
ZMQ_EXPORT
int
zmq_sendmsg
(
zmq_socket_t
s
,
zmq_msg_t
*
msg
,
int
flags
);
ZMQ_EXPORT
int
zmq_recvmsg
(
zmq_socket_t
s
,
zmq_msg_t
*
msg
,
int
flags
);
ZMQ_EXPORT
int
zmq_sendv
(
void
*
s
,
struct
iovec
*
iov
,
size_t
count
,
int
flags
);
ZMQ_EXPORT
int
zmq_recvmmsg
(
void
*
s
,
struct
iovec
*
iov
,
size_t
*
count
,
int
flags
);
ZMQ_EXPORT
int
zmq_sendv
(
zmq_socket_t
s
,
struct
iovec
*
iov
,
size_t
count
,
int
flags
);
ZMQ_EXPORT
int
zmq_recvmmsg
(
zmq_socket_t
s
,
struct
iovec
*
iov
,
size_t
*
count
,
int
flags
);
/******************************************************************************/
/* I/O multiplexing. */
...
...
@@ -228,7 +255,7 @@ ZMQ_EXPORT int zmq_recvmmsg (void *s, struct iovec *iov, size_t *count, int flag
typedef
struct
{
void
*
socket
;
zmq_socket_t
socket
;
#if defined _WIN32
SOCKET
fd
;
#else
...
...
src/zmq.cpp
View file @
a908ccbf
...
...
@@ -18,6 +18,8 @@
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define ZMQ_TYPE_UNSAFE
#include "../include/zmq.h"
#include "platform.hpp"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment