public enum SocketType extends java.lang.Enum<SocketType>
Enum Constant and Description |
---|
CHANNEL
Flag to specify CHANNEL socket.
|
CLIENT
Flag to specify CLIENT socket.
|
DEALER
Flag to specify a DEALER socket (aka XREQ).
|
DISH
Flag to specify DISH socket.
|
GATHER
Flag to specify GATHER socket.
|
PAIR
Flag to specify a exclusive pair of sockets.
|
PEER
Flag to specify PEER socket.
|
PUB
Flag to specify a PUB socket, receiving side must be a SUB or XSUB.
|
PULL
Flag to specify the receiving part of a PUSH socket.
|
PUSH
Flag to specify a PUSH socket, receiving side must be a PULL.
|
RADIO
Flag to specify RADIO socket.
|
RAW
Flag to specify RAW socket.
|
REP
Flag to specify the receiving part of a REQ or DEALER socket.
|
REQ
Flag to specify a REQ socket, receiving side must be a REP or ROUTER.
|
ROUTER
Flag to specify ROUTER socket (aka XREP).
|
SCATTER
Flag to specify SCATTER socket.
|
SERVER
Flag to specify SERVER socket.
|
STREAM
Flag to specify a STREAM socket.
|
SUB
Flag to specify the receiving part of the PUB or XPUB socket.
|
XPUB
Flag to specify a XPUB socket, receiving side must be a SUB or XSUB.
|
XSUB
Flag to specify the receiving part of the PUB or XPUB socket.
|
Modifier and Type | Field and Description |
---|---|
int |
type |
Modifier and Type | Method and Description |
---|---|
int |
type() |
static SocketType |
type(int baseType) |
static SocketType |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static SocketType[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final SocketType PAIR
Flag to specify a exclusive pair of sockets.
A socket of type PAIR can only be connected to a single peer at any one time.
Compatible peer sockets | PAIR |
Direction | Bidirectional |
Send/receive pattern | Unrestricted |
Incoming routing strategy | N/A |
Outgoing routing strategy | N/A |
Action in mute state | Block |
PAIR sockets are designed for inter-thread communication across the inproc transport and do not implement functionality such as auto-reconnection. PAIR sockets are considered experimental and may have other missing or broken aspects.
public static final SocketType PUB
Flag to specify a PUB socket, receiving side must be a SUB or XSUB.
A socket of type PUB is used by a publisher to distribute data.ZMQ.Socket.recv()
function is not implemented for this socket type.
Compatible peer sockets | ZMQ.SUB , ZMQ.XSUB |
Direction | Unidirectional |
Send/receive pattern | Send only |
Incoming routing strategy | N/A |
Outgoing routing strategy | Fan out |
Action in mute state | Drop |
public static final SocketType SUB
Flag to specify the receiving part of the PUB or XPUB socket.
A socket of type SUB is used by a subscriber to subscribe to data distributed by a publisher.ZMQ.Socket.subscribe(byte[])
option to specify which messages to subscribe to.
Compatible peer sockets | ZMQ.PUB , ZMQ.XPUB |
Direction | Unidirectional |
Send/receive pattern | Receive only |
Incoming routing strategy | Fair-queued |
Outgoing routing strategy | N/A |
public static final SocketType REQ
Flag to specify a REQ socket, receiving side must be a REP or ROUTER.
A socket of type REQ is used by a client to send requests to and receive replies from a service.
Compatible peer sockets | ZMQ.REP , ZMQ.ROUTER |
Direction | Bidirectional |
Send/receive pattern | Send, Receive, Send, Receive, ... |
Incoming routing strategy | Last peer |
Outgoing routing strategy | Round-robin |
Action in mute state | Block |
public static final SocketType REP
Flag to specify the receiving part of a REQ or DEALER socket.
A socket of type REP is used by a service to receive requests from and send replies to a client.
Compatible peer sockets | ZMQ.REQ , ZMQ.DEALER |
Direction | Bidirectional |
Send/receive pattern | Receive, Send, Receive, Send, ... |
Incoming routing strategy | Fair-queued |
Outgoing routing strategy | Last peer |
public static final SocketType DEALER
Flag to specify a DEALER socket (aka XREQ).
DEALER is really a combined ventilator / sink that does load-balancing on output and fair-queuing on input with no other semantics. It is the only socket type that lets you shuffle messages out to N nodes and shuffle the replies back, in a raw bidirectional asynch pattern.ZMQ.REP
socket each message sent must consist of
an empty message part, the delimiter, followed by one or more body parts.
Compatible peer sockets | ZMQ.ROUTER , ZMQ.REP , ZMQ.DEALER |
Direction | Bidirectional |
Send/receive pattern | Unrestricted |
Incoming routing strategy | Fair-queued |
Outgoing routing strategy | Round-robin |
Action in mute state | Block |
public static final SocketType ROUTER
Flag to specify ROUTER socket (aka XREP).
ROUTER is the socket that creates and consumes request-reply routing envelopes. It is the only socket type that lets you route messages to specific connections if you know their identities.ZMQ.Socket.setRouterMandatory(boolean)
socket option is set to true.
ZMQ.Socket.setRouterMandatory(boolean)
socket option is set to true.
ZMQ.REQ
socket is connected to a ROUTER socket, in addition to the identity of the originating peer
each message received shall contain an empty delimiter message part.
Compatible peer sockets | ZMQ.DEALER , ZMQ.REQ , ZMQ.ROUTER |
Direction | Bidirectional |
Send/receive pattern | Unrestricted |
Incoming routing strategy | Fair-queued |
Outgoing routing strategy | See text |
Action in mute state | Drop (See text) |
public static final SocketType PULL
Flag to specify the receiving part of a PUSH socket.
A socket of type ZMQ_PULL is used by a pipeline node to receive messages from upstream pipeline nodes.
Compatible peer sockets | ZMQ.PUSH |
Direction | Unidirectional |
Send/receive pattern | Receive only |
Incoming routing strategy | Fair-queued |
Outgoing routing strategy | N/A |
Action in mute state | Block |
public static final SocketType PUSH
Flag to specify a PUSH socket, receiving side must be a PULL.
A socket of type PUSH is used by a pipeline node to send messages to downstream pipeline nodes.
Compatible peer sockets | ZMQ.PULL |
Direction | Unidirectional |
Send/receive pattern | Send only |
Incoming routing strategy | N/A |
Outgoing routing strategy | Round-robin |
Action in mute state | Block |
public static final SocketType XPUB
Flag to specify a XPUB socket, receiving side must be a SUB or XSUB.
Subscriptions can be received as a message. Subscriptions start with a '1' byte. Unsubscriptions start with a '0' byte.ZMQ.PUB
except that you can receive subscriptions from the peers in form of incoming messages.
Compatible peer sockets | ZMQ.SUB , ZMQ.XSUB |
Direction | Unidirectional |
Send/receive pattern | Send messages, receive subscriptions |
Incoming routing strategy | N/A |
Outgoing routing strategy | Fan out |
Action in mute state | Drop |
public static final SocketType XSUB
Flag to specify the receiving part of the PUB or XPUB socket.
Same asZMQ.SUB
except that you subscribe by sending subscription messages to the socket.
Compatible peer sockets | ZMQ.PUB , ZMQ.XPUB |
Direction | Unidirectional |
Send/receive pattern | Receive messages, send subscriptions |
Incoming routing strategy | Fair-queued |
Outgoing routing strategy | N/A |
Action in mute state | Drop |
public static final SocketType STREAM
Flag to specify a STREAM socket.
A socket of type STREAM is used to send and receive TCP data from a non-ØMQ peer, when using the tcp:// transport. A STREAM socket can act as client and/or server, sending and/or receiving TCP data asynchronously.ZMQ.Socket.connect(String)
call, and then fetch the socket identity using the ZMQ.Socket.getIdentity()
call.
To close a specific connection, send the identity frame followed by a zero-length message.
When a connection is made, a zero-length message will be received by the application.
Similarly, when the peer disconnects (or the connection is lost), a zero-length message will be received by the application.
The ZMQ.SNDMORE
flag is ignored on data frames. You must send one identity frame followed by one data frame.
Compatible peer sockets | none |
Direction | Bidirectional |
Send/receive pattern | Unrestricted |
Incoming routing strategy | Fair-queued |
Outgoing routing strategy | See text |
Action in mute state | EAGAIN |
public static final SocketType CLIENT
Flag to specify CLIENT socket.
The CLIENT socket type talks to one or more SERVER peers. If connected to multiple peers, it scatters sent messages among these peers in a round-robin fashion. On reading, it reads fairly, from each peer in turn. It is reliable, insofar as it does not drop messages in normal cases.
If the CLIENT socket has established a connection, send operations will accept messages, queue them, and send them as rapidly as the network allows. The outgoing buffer limit is defined by the high water mark for the socket. If the outgoing buffer is full, or if there is no connected peer, send operations will block, by default. The CLIENT socket will not drop messages.
CLIENT sockets are threadsafe. They do not accept the ZMQ_SNDMORE option on sends not ZMQ_RCVMORE on receives. This limits them to single part data. The intention is to extend the API to allow scatter/gather of multi-part data.
Compatible peer sockets | SERVER |
Direction | Bidirectional |
Send/receive pattern | Unrestricted |
Outgoing routing strategy | Round Robin |
Incoming routing strategy | Fair-queued |
Action in mute state | Block |
public static final SocketType SERVER
Flag to specify SERVER socket.
The SERVER socket type talks to zero or more CLIENT peers. Each outgoing message is sent to a specific peer CLIENT. A SERVER socket can only reply to an incoming message: the CLIENT peer must always initiate a conversation.
Each received message has a routing_id that is a 32-bit unsigned integer. To send a message to a given CLIENT peer the application must set the peer’s routing_id on the message.
SERVER sockets are threadsafe. They do not accept the ZMQ_SNDMORE option on sends not ZMQ_RCVMORE on receives. This limits them to single part data. The intention is to extend the API to allow scatter/gather of multi-part data.
Compatible peer sockets | CLIENT |
Direction | Bidirectional |
Send/receive pattern | Unrestricted |
Outgoing routing strategy | See text |
Incoming routing strategy | Fair-queued |
Action in mute state | Fail |
public static final SocketType RADIO
Flag to specify RADIO socket.
The radio-dish pattern is used for one-to-many distribution of data from a single publisher to multiple subscribers in a fan out fashion. Radio-dish is using groups (vs Pub-sub topics), Dish sockets can join a group and each message sent by Radio sockets belong to a group.
Groups are strings limited to 16 chars length (including null). The intention is to increase the length to 40 chars (including null). The encoding of groups shall be UTF8. Groups are matched using exact matching (vs prefix matching of PubSub).
A socket of type RADIO is used by a publisher to distribute data.
Each message belong to a group, a group is specified with ZFrame.setGroup(String)
.
Messages are distributed to all members of a group.
The ZMQ.Socket.recv(int)
function is not implemented for this socket type.
When a RADIO socket enters the mute state due to having reached the high water mark for a subscriber,
then any messages that would be sent to the subscriber in question shall instead be dropped
until the mute state ends. The ZMQ.Socket.send(byte[], int)
function shall never block for this socket type.
NOTE: RADIO sockets are threadsafe. They do not accept the ZMQ_SNDMORE option on sends. This limits them to single part data.
Compatible peer sockets | DISH |
Direction | Unidirectional |
Send/receive pattern | Send only |
Outgoing routing strategy | Fan out |
Incoming routing strategy | N/A |
Action in mute state | Drop |
NOTE: RADIO is still in draft phase.
public static final SocketType DISH
Flag to specify DISH socket.
The radio-dish pattern is used for one-to-many distribution of data from a single publisher to multiple subscribers in a fan out fashion. Radio-dish is using groups (vs Pub-sub topics), Dish sockets can join a group and each message sent by Radio sockets belong to a group.
Groups are strings limited to 16 chars length (including null). The intention is to increase the length to 40 chars (including null). The encoding of groups shall be UTF8. Groups are matched using exact matching (vs prefix matching of PubSub).
A socket of type DISH is used by a subscriber to subscribe to groups distributed by a radio. Initially a DISH socket is not subscribed to any groups, useZMQ.Socket.join(String)
to join a group.
To get the group the message belong, call ZFrame.getGroup()
.
The ZMQ.Socket.send(byte[], int)
function is not implemented for this socket type.
NOTE: DISH sockets are threadsafe. They do not accept ZMQ_RCVMORE on receives. This limits them to single part data.
Compatible peer sockets | RADIO |
Direction | Unidirectional |
Send/receive pattern | Receive only |
Outgoing routing strategy | N/A |
Incoming routing strategy | Fair-queued |
public static final SocketType CHANNEL
Flag to specify CHANNEL socket.
The channel pattern is the thread-safe version of the exclusive pair pattern. The channel pattern is used to connect a peer to precisely one other peer. This pattern is used for inter-thread communication across the inproc transport.
A socket of type 'CHANNEL' can only be connected to a single peer at any one time. No message routing or filtering is performed on messages sent over a 'CHANNEL' socket.
When a 'CHANNEL' socket enters the 'mute' state due to having reached the
high water mark for the connected peer, or, for connection-oriented transports,
if the ZMQ_IMMEDIATE option is set and there is no connected peer, then
any ZMQ.Socket.send(byte[], int)
operations on the socket shall block until the peer
becomes available for sending; messages are not discarded.
While 'CHANNEL' sockets can be used over transports other than 'inproc', their inability to auto-reconnect coupled with the fact new incoming connections will be terminated while any previous connections (including ones in a closing state) exist makes them unsuitable for TCP in most cases.
NOTE: 'CHANNEL' sockets are designed for inter-thread communication across the 'inproc' transport and do not implement functionality such as auto-reconnection.
NOTE: 'CHANNEL' sockets are threadsafe. They do not accept ZMQ_RCVMORE on receives. This limits them to single part data.
Compatible peer sockets | CHANNEL |
Direction | Bidirectional |
Send/receive pattern | Unrestricted |
Outgoing routing strategy | N/A |
Incoming routing strategy | N/A |
Action in mute state | Block |
NOTE: CHANNEL is still in draft phase.
public static final SocketType PEER
Flag to specify PEER socket.
A 'PEER' socket talks to a set of 'PEER' sockets.
To connect and fetch the 'routing_id' of the peer use ZMQ.Socket.connectPeer(String)
.
Each received message has a 'routing_id' that is a 32-bit unsigned integer.
The application can fetch this with ZFrame.getRoutingId()
.
To send a message to a given 'PEER' peer the application must set the peer's
'routing_id' on the message, using ZFrame.setRoutingId(int)
.
If the 'routing_id' is not specified, or does not refer to a connected client peer, the send call will fail with EHOSTUNREACH. If the outgoing buffer for the peer is full, the send call shall block, unless ZMQ_DONTWAIT is used in the send, in which case it shall fail with EAGAIN. The 'PEER' socket shall not drop messages in any case.
NOTE: 'PEER' sockets are threadsafe. They do not accept the ZMQ_SNDMORE option on sends not ZMQ_RCVMORE on receives. This limits them to single part data.
Compatible peer sockets | PEER |
Direction | Bidirectional |
Send/receive pattern | Unrestricted |
Outgoing routing strategy | See text |
Incoming routing strategy | Fair-queued |
Action in mute state | Return EAGAIN |
public static final SocketType RAW
Flag to specify RAW socket.
public static final SocketType SCATTER
Flag to specify SCATTER socket.
The scatter-gather pattern is the thread-safe version of the pipeline pattern. The scatter-gather pattern is used for distributing data to nodes arranged in a pipeline. Data always flows down the pipeline, and each stage of the pipeline is connected to at least one node. When a pipeline stage is connected to multiple nodes data is round-robined among all connected nodes.
When a 'SCATTER' socket enters the 'mute' state due to having reached the
high water mark for all downstream nodes, or, for connection-oriented transports,
if the ZMQ_IMMEDIATE option is set and there are no downstream nodes at all,
then any ZMQ.Socket.send(byte[], int)
operations on the socket shall block until the mute
state ends or at least one downstream node becomes available for sending;
messages are not discarded.
NOTE: 'SCATTER' sockets are threadsafe. They do not accept ZMQ_RCVMORE on receives. This limits them to single part data.
Compatible peer sockets | GATHER |
Direction | Unidirectional |
Send/receive pattern | Send only |
Outgoing routing strategy | Round-robin |
Incoming routing strategy | N/A |
Action in mute state | Block |
public static final SocketType GATHER
Flag to specify GATHER socket.
The scatter-gather pattern is the thread-safe version of the pipeline pattern. The scatter-gather pattern is used for distributing data to nodes arranged in a pipeline. Data always flows down the pipeline, and each stage of the pipeline is connected to at least one node. When a pipeline stage is connected to multiple nodes data is round-robined among all connected nodes.
A socket of type 'GATHER' is used by a scatter-gather node to receive messages
from upstream scatter-gather nodes. Messages are fair-queued from among all
connected upstream nodes. The ZMQ.Socket.send(byte[], int)
function is not implemented for
this socket type.
NOTE: 'GATHER' sockets are threadsafe. They do not accept ZMQ_RCVMORE on receives. This limits them to single part data.
Compatible peer sockets | SCATTER |
Direction | Unidirectional |
Send/receive pattern | Receive only |
Outgoing routing strategy | N/A |
Incoming routing strategy | Fair-queued |
Action in mute state | Block |
public static SocketType[] values()
for (SocketType c : SocketType.values()) System.out.println(c);
public static SocketType valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is nullpublic static SocketType type(int baseType)
public int type()