Skip to content

Commit

Permalink
Merge pull request zeromq#220 from 250bpm/HEAD
Browse files Browse the repository at this point in the history
Refactoring
  • Loading branch information
sustrik committed Nov 4, 2011
2 parents 541b83b + e9c3a22 commit 6cdd720
Show file tree
Hide file tree
Showing 163 changed files with 675 additions and 1,660 deletions.
20 changes: 10 additions & 10 deletions COPYING.LESSER
Expand Up @@ -166,16 +166,16 @@ Library.

--------------------------------------------------------------------------------

SPECIAL EXCEPTION GRANTED BY IMATIX

As a special exception, iMatix gives you permission to link this library with
independent modules to produce an executable, regardless of the license terms
of these independent modules, and to copy and distribute the resulting
executable under terms of your choice, provided that you also meet, for each
linked independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from or based on
this library. If you modify this library, you must extend this exception to your
version of the library.
SPECIAL EXCEPTION GRANTED BY COPYRIGHT HOLDERS

As a special exception, copyright holders give you permission to link this
library with independent modules to produce an executable, regardless of
the license terms of these independent modules, and to copy and distribute
the resulting executable under terms of your choice, provided that you also
meet, for each linked independent module, the terms and conditions of
the license of that module. An independent module is a module which is not
derived from or based on this library. If you modify this library, you must
extend this exception to your version of the library.

--------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion autogen.sh
@@ -1,6 +1,6 @@
#!/bin/sh

# Copyright (c) 2007-2011 iMatix Corporation
# Copyright (c) 2007-2009 iMatix Corporation
# Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
#
# This file is part of 0MQ.
Expand Down
13 changes: 0 additions & 13 deletions configure.in
Expand Up @@ -348,19 +348,6 @@ fi

AC_SUBST(pgm_basename)

# VTCP extension
libzmq_vtcp="no"

AC_ARG_WITH([vtcp], [AS_HELP_STRING([--with-vtcp],
[build libzmq with VTCP extension [default=no]])],
[with_vtcp=$withval], [with_vtcp=no])

if test "x$with_vtcp" != "xno"; then
AC_DEFINE(ZMQ_HAVE_VTCP, 1, [Have VTCP extension])
AC_CHECK_LIB(vtcp, vtcp_bind, ,
[AC_MSG_ERROR([cannot link with -lvtcp, install libvtcp.])])
fi

# Set -Wall, -Werror and -pedantic
AC_LANG_PUSH([C++])

Expand Down
29 changes: 16 additions & 13 deletions doc/zmq_getsockopt.txt
Expand Up @@ -39,19 +39,6 @@ Default value:: N/A
Applicable socket types:: all


ZMQ_RCVLABEL: Inquires whether last message received was a label
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The 'ZMQ_RCVLABEL' option shall return True (1) if the message part last
received from the 'socket' was an address label. Otherwise, this option
shall return False (0).

[horizontal]
Option value type:: int
Option value unit:: boolean
Default value:: N/A
Applicable socket types:: all


ZMQ_RCVMORE: More message data parts to follow
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The 'ZMQ_RCVMORE' option shall return True (1) if the message part last
Expand Down Expand Up @@ -130,6 +117,22 @@ Option value unit:: N/A (bitmap)
Default value:: 0
Applicable socket types:: N/A

ZMQ_IDENTITY: Set socket identity
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The 'ZMQ_IDENTITY' option shall retrieve the identity of the specified 'socket'.
Socket identity is used only by request/reply pattern. Namely, it can be used
in tandem with ROUTER socket to route messages to the peer with specific
identity.

Identity should be at least one byte and at most 255 bytes long. Identities
starting with binary zero are reserved for use by 0MQ infrastructure.

[horizontal]
Option value type:: binary data
Option value unit:: N/A
Default value:: NULL
Applicable socket types:: all


ZMQ_RATE: Retrieve multicast data rate
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
7 changes: 2 additions & 5 deletions doc/zmq_recv.txt
Expand Up @@ -29,18 +29,15 @@ function shall fail with 'errno' set to EAGAIN.

Multi-part messages
~~~~~~~~~~~~~~~~~~~
A 0MQ message is composed of 1 or more message parts, starting with zero or
more address 'label' parts, followed by 1 or more 'data' parts. Each message
A 0MQ message is composed of 1 or more message parts. Each message
part is an independent 'zmq_msg_t' in its own right. 0MQ ensures atomic
delivery of messages; peers shall receive either all _message parts_ of a
message or none at all. The total number of message parts is unlimited except
by available memory.

An application that processes multipart messages must use the _ZMQ_RCVMORE_
linkzmq:zmq_getsockopt[3] option after calling _zmq_recv()_ to determine if
there are further parts to receive. An application that manipulates address
labels must use _ZMQ_RCVLABEL_ to determine the zero or more label parts
that precede the data part(s).
there are further parts to receive.

RETURN VALUE
------------
Expand Down
7 changes: 2 additions & 5 deletions doc/zmq_recvmsg.txt
Expand Up @@ -29,18 +29,15 @@ function shall fail with 'errno' set to EAGAIN.

Multi-part messages
~~~~~~~~~~~~~~~~~~~
A 0MQ message is composed of 1 or more message parts, starting with zero or
more address 'label' parts, followed by 1 or more 'data' parts. Each message
A 0MQ message is composed of 1 or more message parts. Each message
part is an independent 'zmq_msg_t' in its own right. 0MQ ensures atomic
delivery of messages; peers shall receive either all _message parts_ of a
message or none at all. The total number of message parts is unlimited except
by available memory.

An application that processes multipart messages must use the _ZMQ_RCVMORE_
linkzmq:zmq_getsockopt[3] option after calling _zmq_recvmsg()_ to determine if
there are further parts to receive. An application that manipulates address
labels must use _ZMQ_RCVLABEL_ to determine the zero or more label parts
that precede the data part(s).
there are further parts to receive.


RETURN VALUE
Expand Down
11 changes: 2 additions & 9 deletions doc/zmq_send.txt
Expand Up @@ -23,11 +23,6 @@ Specifies that the operation should be performed in non-blocking mode. If the
message cannot be queued on the 'socket', the _zmq_send()_ function shall
fail with 'errno' set to EAGAIN.

*ZMQ_SNDLABEL*::
Specifies that the message part being sent is an address label, and that
further message parts are to follow. Refer to linkzmq:zmq_socket[3] for the
semantics of address labels in each socket pattern.

*ZMQ_SNDMORE*::
Specifies that the message being sent is a multi-part message, and that further
message parts are to follow. Refer to the section regarding multi-part messages
Expand All @@ -40,16 +35,14 @@ the 'socket' and 0MQ has assumed responsibility for the message.

Multi-part messages
~~~~~~~~~~~~~~~~~~~
A 0MQ message is composed of 1 or more message parts, starting with zero or
more address 'label' parts, followed by 1 or more 'data' parts. Each message
A 0MQ message is composed of 1 or more message parts. Each message
part is an independent 'zmq_msg_t' in its own right. 0MQ ensures atomic
delivery of messages; peers shall receive either all _message parts_ of a
message or none at all. The total number of message parts is unlimited except
by available memory.

An application that sends multipart messages must use the _ZMQ_SNDMORE_ flag
when sending each data part except the final one. An application that sends
address labels must use _ZMQ_SNDLABEL_ when sending each label.
when sending each data part except the final one.


RETURN VALUE
Expand Down
11 changes: 2 additions & 9 deletions doc/zmq_sendmsg.txt
Expand Up @@ -23,11 +23,6 @@ Specifies that the operation should be performed in non-blocking mode. If the
message cannot be queued on the 'socket', the _zmq_sendmsg()_ function shall
fail with 'errno' set to EAGAIN.

*ZMQ_SNDLABEL*::
Specifies that the message part being sent is an address 'label', and that
further message parts are to follow. Refer to linkzmq:zmq_socket[3] for the
semantics of address labels in each socket pattern.

*ZMQ_SNDMORE*::
Specifies that the message being sent is a multi-part message, and that further
message parts are to follow. Refer to the section regarding multi-part messages
Expand All @@ -44,16 +39,14 @@ the 'socket' and 0MQ has assumed responsibility for the message.

Multi-part messages
~~~~~~~~~~~~~~~~~~~
A 0MQ message is composed of 1 or more message parts, starting with zero or
more address 'label' parts, followed by 1 or more 'data' parts. Each message
A 0MQ message is composed of 1 or more message parts. Each message
part is an independent 'zmq_msg_t' in its own right. 0MQ ensures atomic
delivery of messages; peers shall receive either all _message parts_ of a
message or none at all. The total number of message parts is unlimited except
by available memory.

An application that sends multipart messages must use the _ZMQ_SNDMORE_ flag
when sending each data part except the final one. An application that sends
address labels must use _ZMQ_SNDLABEL_ when sending each label.
when sending each data part except the final one.

RETURN VALUE
------------
Expand Down
17 changes: 17 additions & 0 deletions doc/zmq_setsockopt.txt
Expand Up @@ -122,6 +122,23 @@ Default value:: N/A
Applicable socket types:: ZMQ_SUB


ZMQ_IDENTITY: Set socket identity
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The 'ZMQ_IDENTITY' option shall set the identity of the specified 'socket'.
Socket identity is used only by request/reply pattern. Namely, it can be used
in tandem with ROUTER socket to route messages to the peer with specific
identity.

Identity should be at least one byte and at most 255 bytes long. Identities
starting with binary zero are reserved for use by 0MQ infrastructure.

[horizontal]
Option value type:: binary data
Option value unit:: N/A
Default value:: NULL
Applicable socket types:: all


ZMQ_RATE: Set multicast data rate
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The 'ZMQ_RATE' option shall set the maximum send or receive data rate for
Expand Down
33 changes: 0 additions & 33 deletions doc/zmq_socket.txt
Expand Up @@ -81,11 +81,6 @@ any linkzmq:zmq_send[3] operations on the socket shall block until the
exceptional state ends or at least one _service_ becomes available for sending;
messages are not discarded.

'ZMQ_REQ' socket adds a unique 'request ID' label to every outbound message.
When receiving a reply, it checks whether the 'request ID' of the reply matches
the last 'request ID' sent. If it does not, the message is silently dropped and
waiting for the reply is resumed.

[horizontal]
.Summary of ZMQ_REQ characteristics
Compatible peer sockets:: 'ZMQ_REP'
Expand All @@ -108,10 +103,6 @@ When a 'ZMQ_REP' socket enters an exceptional state due to having reached the
high water mark for a _client_, then any replies sent to the _client_ in
question shall be dropped until the exceptional state ends.

'ZMQ_REP' socket strips all the labels from the incoming message, stores them
and passes the remaining data parts to the user. When user sends the reply,
the stored labels are re-attached to the reply.

[horizontal]
.Summary of ZMQ_REP characteristics
Compatible peer sockets:: 'ZMQ_REQ'
Expand All @@ -136,8 +127,6 @@ linkzmq:zmq_send[3] operations on the socket shall block until the exceptional
state ends or at least one peer becomes available for sending; messages are not
discarded.

'ZMQ_XREQ' socket doesn't inspect or modify the message labels.

[horizontal]
.Summary of ZMQ_XREQ characteristics
Compatible peer sockets:: 'ZMQ_XREP', 'ZMQ_REP'
Expand All @@ -162,14 +151,6 @@ messages sent to the socket shall be dropped until the exceptional state ends.
Likewise, any messages to be routed to a non-existent peer or a peer for which
the individual high water mark has been reached shall also be dropped.

When receiving messages a 'ZMQ_XREP' socket attaches a label uniquely
identifying the originating peer to the message before passing it to the
application.

When sending messages a 'ZMQ_XREP' socket removes the first label from the
message and uses it to determine which the peer the message shall be routed to.
If the peer does not exist anymore the message is silently discarded.

[horizontal]
.Summary of ZMQ_XREP characteristics
Compatible peer sockets:: 'ZMQ_XREQ', 'ZMQ_REQ'
Expand All @@ -196,8 +177,6 @@ high water mark for a _subscriber_, then any messages that would be sent to the
_subscriber_ in question shall instead be dropped until the exceptional state
ends. The _zmq_send()_ function shall never block for this socket type.

This socket type doesn't use message labels.

[horizontal]
.Summary of ZMQ_PUB characteristics
Compatible peer sockets:: 'ZMQ_SUB', 'ZMQ_XSUB'
Expand All @@ -215,8 +194,6 @@ any messages, use the 'ZMQ_SUBSCRIBE' option of linkzmq:zmq_setsockopt[3] to
specify which messages to subscribe to. The _zmq_send()_ function is not
implemented for this socket type.

This socket type doesn't use message labels.

[horizontal]
.Summary of ZMQ_SUB characteristics
Compatible peer sockets:: 'ZMQ_PUB', 'ZMQ_XPUB'
Expand All @@ -233,8 +210,6 @@ in form of incoming messages. Subscription message is a byte 1 (for
subscriptions) or byte 0 (for unsubscriptions) followed by the subscription
body.

This socket type doesn't use message labels.

[horizontal]
.Summary of ZMQ_XPUB characteristics
Compatible peer sockets:: 'ZMQ_SUB', 'ZMQ_XSUB'
Expand All @@ -250,8 +225,6 @@ Same as ZMQ_SUB except that you subscribe by sending subscription messages to
the socket. Subscription message is a byte 1 (for subscriptions) or byte 0
(for unsubscriptions) followed by the subscription body.

This socket type doesn't use message labels.

[horizontal]
.Summary of ZMQ_XSUB characteristics
Compatible peer sockets:: 'ZMQ_PUB', 'ZMQ_XPUB'
Expand Down Expand Up @@ -282,8 +255,6 @@ _nodes_ at all, then any linkzmq:zmq_send[3] operations on the socket shall
block until the exceptional state ends or at least one downstream _node_
becomes available for sending; messages are not discarded.

This socket type doesn't use message labels.

[horizontal]
.Summary of ZMQ_PUSH characteristics
Compatible peer sockets:: 'ZMQ_PULL'
Expand All @@ -301,8 +272,6 @@ from upstream pipeline _nodes_. Messages are fair-queued from among all
connected upstream _nodes_. The _zmq_send()_ function is not implemented for
this socket type.

This socket type doesn't use message labels.

[horizontal]
.Summary of ZMQ_PULL characteristics
Compatible peer sockets:: 'ZMQ_PUSH'
Expand Down Expand Up @@ -330,8 +299,6 @@ high water mark for the connected peer, or if no peer is connected, then
any linkzmq:zmq_send[3] operations on the socket shall block until the peer
becomes available for sending; messages are not discarded.

This socket type doesn't use message labels.

NOTE: 'ZMQ_PAIR' sockets are experimental, and are currently missing several
features such as auto-reconnection.

Expand Down
13 changes: 7 additions & 6 deletions include/zmq.h
@@ -1,5 +1,7 @@
/*
Copyright (c) 2007-2011 iMatix Corporation
Copyright (c) 2009-2011 250bpm s.r.o.
Copyright (c) 2007-2010 iMatix Corporation
Copyright (c) 2011 VMware, Inc.
Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
This file is part of 0MQ.
Expand Down Expand Up @@ -162,10 +164,13 @@ ZMQ_EXPORT int zmq_term (void *context);
#define ZMQ_PUSH 8
#define ZMQ_XPUB 9
#define ZMQ_XSUB 10
#define ZMQ_ROUTER 13

#define ZMQ_ROUTER ZMQ_XREP
#define ZMQ_DEALER ZMQ_XREQ

/* Socket options. */
#define ZMQ_AFFINITY 4
#define ZMQ_IDENTITY 5
#define ZMQ_SUBSCRIBE 6
#define ZMQ_UNSUBSCRIBE 7
#define ZMQ_RATE 8
Expand All @@ -186,15 +191,11 @@ ZMQ_EXPORT int zmq_term (void *context);
#define ZMQ_MULTICAST_HOPS 25
#define ZMQ_RCVTIMEO 27
#define ZMQ_SNDTIMEO 28
#define ZMQ_RCVLABEL 29
#define ZMQ_RCVCMD 30
#define ZMQ_IPV4ONLY 31

/* Send/recv options. */
#define ZMQ_DONTWAIT 1
#define ZMQ_SNDMORE 2
#define ZMQ_SNDLABEL 4
#define ZMQ_SNDCMD 8

ZMQ_EXPORT void *zmq_socket (void *context, int type);
ZMQ_EXPORT int zmq_close (void *s);
Expand Down
2 changes: 1 addition & 1 deletion include/zmq_utils.h
@@ -1,5 +1,5 @@
/*
Copyright (c) 2007-2011 iMatix Corporation
Copyright (c) 2009-2011 250bpm s.r.o.
Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
This file is part of 0MQ.
Expand Down
3 changes: 2 additions & 1 deletion perf/inproc_lat.cpp
@@ -1,5 +1,6 @@
/*
Copyright (c) 2007-2011 iMatix Corporation
Copyright (c) 2009-2011 250bpm s.r.o.
Copyright (c) 2007-2009 iMatix Corporation
Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
This file is part of 0MQ.
Expand Down
3 changes: 2 additions & 1 deletion perf/inproc_thr.cpp
@@ -1,5 +1,6 @@
/*
Copyright (c) 2007-2011 iMatix Corporation
Copyright (c) 2009-2011 250bpm s.r.o.
Copyright (c) 2007-2009 iMatix Corporation
Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
This file is part of 0MQ.
Expand Down

0 comments on commit 6cdd720

Please sign in to comment.