Enum Class SocketType
- All Implemented Interfaces:
Serializable
,Comparable<SocketType>
,Constable
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionFlag to specify a DEALER socket (aka XREQ).Flag to specify a exclusive pair of sockets.Flag to specify a PUB socket, receiving side must be a SUB or XSUB.Flag to specify the receiving part of a PUSH socket.Flag to specify a PUSH socket, receiving side must be a PULL.Flag to specify the receiving part of a REQ or DEALER socket.Flag to specify a REQ socket, receiving side must be a REP or ROUTER.Flag to specify ROUTER socket (aka XREP).Flag to specify a STREAM socket.Flag to specify the receiving part of the PUB or XPUB socket.Flag to specify a XPUB socket, receiving side must be a SUB or XSUB.Flag to specify the receiving part of the PUB or XPUB socket. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
type()
static SocketType
type
(int baseType) static SocketType
Returns the enum constant of this class with the specified name.static SocketType[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
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.
No message routing or filtering is performed on messages sent over a PAIR socket.
When a PAIR socket enters the mute state due to having reached the high water mark for the connected peer, or if no peer is connected, then any send() operations on the socket shall block until the peer becomes available for sending; messages are not discarded.
Summary of socket characteristics 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.
-
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.
Messages sent are distributed in a fan out fashion to all connected peers.
TheZMQ.Socket.recv()
function is not implemented for this socket type.
When a PUB 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 send methods shall never block for this socket type.
Summary of socket characteristics 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 -
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.
Initially a SUB socket is not subscribed to any messages, use theZMQ.Socket.subscribe(byte[])
option to specify which messages to subscribe to.
The send methods are not implemented for this socket type.
Summary of socket characteristics Compatible peer sockets ZMQ.PUB
,ZMQ.XPUB
Direction Unidirectional Send/receive pattern Receive only Incoming routing strategy Fair-queued Outgoing routing strategy N/A -
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.
This socket type allows only an alternating sequence of send(request) and subsequent recv(reply) calls.
Each request sent is round-robined among all services, and each reply received is matched with the last issued request.
If no services are available, then any send operation on the socket shall block until at least one service becomes available.
The REQ socket shall not discard messages.
Summary of socket characteristics 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 -
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.
This socket type allows only an alternating sequence of recv(request) and subsequent send(reply) calls.
Each request received is fair-queued from among all clients, and each reply sent is routed to the client that issued the last request.
If the original requester does not exist any more the reply is silently discarded.
Summary of socket characteristics 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 -
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.
A socket of type DEALER is an advanced pattern used for extending request/reply sockets.
Each message sent is round-robined among all connected peers, and each message received is fair-queued from all connected peers.
When a DEALER socket enters the mute state due to having reached the high water mark for all peers, or if there are no peers at all, then any send() operations on the socket shall block until the mute state ends or at least one peer becomes available for sending; messages are not discarded.
When a DEALER socket is connected to aZMQ.REP
socket each message sent must consist of an empty message part, the delimiter, followed by one or more body parts.
Summary of socket characteristics 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 -
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.
A socket of type ROUTER is an advanced socket type used for extending request/reply sockets.
When receiving messages a ROUTER socket shall prepend a message part containing the identity of the originating peer to the message before passing it to the application.
Messages received are fair-queued from among all connected peers.
When sending messages a ROUTER socket shall remove the first part of the message and use it to determine the identity of the peer the message shall be routed to. If the peer does not exist anymore the message shall be silently discarded by default, unlessZMQ.Socket.setRouterMandatory(boolean)
socket option is set to true.
When a ROUTER socket enters the mute state due to having reached the high water mark for all peers, then any messages sent to the socket shall be dropped until the mute state ends.
Likewise, any messages routed to a peer for which the individual high water mark has been reached shall also be dropped, unlessZMQ.Socket.setRouterMandatory(boolean)
socket option is set to true.
When aZMQ.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.
Hence, the entire structure of each received message as seen by the application becomes: one or more identity parts, delimiter part, one or more body parts.
When sending replies to a REQ socket the application must include the delimiter part.
Summary of socket characteristics 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) -
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.
Messages are fair-queued from among all connected upstream nodes.
The send() function is not implemented for this socket type.
Summary of socket characteristics 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 -
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.
Messages are round-robined to all connected downstream nodes.
The recv() function is not implemented for this socket type.
When a PUSH socket enters the mute state due to having reached the high water mark for all downstream nodes, or if there are no downstream nodes at all, then any send() 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.
Summary of socket characteristics 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 -
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.
Same asZMQ.PUB
except that you can receive subscriptions from the peers in form of incoming messages.
Subscription message is a byte '1' (for subscriptions) or byte '0' (for unsubscriptions) followed by the subscription body.
Messages without a sub/unsub prefix are also received, but have no effect on subscription status.
Summary of socket characteristics 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 -
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.
Subscription message is a byte '1' (for subscriptions) or byte '0' (for unsubscriptions) followed by the subscription body.
Messages without a sub/unsub prefix may also be sent, but have no effect on subscription status.
Summary of socket characteristics 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 -
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.
When receiving TCP data, a STREAM socket shall prepend a message part containing the identity of the originating peer to the message before passing it to the application.
Messages received are fair-queued from among all connected peers. When sending TCP data, a STREAM socket shall remove the first part of the message and use it to determine the identity of the peer the message shall be routed to, and unroutable messages shall cause an EHOSTUNREACH or EAGAIN error.
To open a connection to a server, use theZMQ.Socket.connect(String)
call, and then fetch the socket identity using theZMQ.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. TheZMQ.SNDMORE
flag is ignored on data frames. You must send one identity frame followed by one data frame.
Also, please note that omitting the SNDMORE flag will prevent sending further data (from any client) on the same socket.
Summary of socket characteristics 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
-
-
Field Details
-
type
public final int type
-
-
Constructor Details
-
SocketType
private SocketType(int socketType)
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
type
-
type
public int type()
-