public static class ZMQ.Socket extends Object implements Closeable
ZMQ.PAIR
, ØMQ sockets may be connected to multiple endpoints using connect(String)
,
while simultaneously accepting incoming connections from multiple endpoints bound to the socket using bind(String)
,
thus allowing many-to-many relationships.
ZMQ.REQ
client to one or more ZMQ.REP
services, and receiving subsequent replies to each request sent.
The request-reply pattern is formally defined by http://rfc.zeromq.org/spec:28.
ZMQ.REQ
, ZMQ.REP
, ZMQ.DEALER
, ZMQ.ROUTER
socket types belong to this pattern.
ZMQ.SUB
, ZMQ.PUB
, ZMQ.XSUB
, ZMQ.XPUB
socket types belong to this pattern.
ZMQ.PUSH
, ZMQ.PULL
socket types belong to this pattern.
ZMQ.PAIR
socket type.
The exclusive pair pattern is formally defined by http://rfc.zeromq.org/spec:31.
ZMQ.STREAM
socket type.
Modifier and Type | Class and Description |
---|---|
static class |
ZMQ.Socket.Mechanism |
Modifier | Constructor and Description |
---|---|
protected |
Socket(SocketBase base) |
protected |
Socket(ZMQ.Context context,
int type)
Deprecated.
use
Socket#Socket(Context, SocketType) |
protected |
Socket(ZMQ.Context context,
SocketType type)
Class constructor.
|
Modifier and Type | Method and Description |
---|---|
SocketBase |
base()
DO NOT USE if you're trying to build a special proxy
|
boolean |
bind(String addr)
Bind to network interface.
|
int |
bindToRandomPort(String addr)
Bind to network interface to a random port.
|
int |
bindToRandomPort(String addr,
int min,
int max)
Bind to network interface to a random port.
|
void |
close()
This is an explicit "destructor".
|
boolean |
connect(String addr)
Connects the socket to an endpoint and then accepts incoming connections on that endpoint.
|
boolean |
disconnect(String addr)
Disconnect from remote application.
|
int |
errno() |
long |
getAffinity() |
boolean |
getAsServerCurve()
Deprecated.
the naming is inconsistent with jzmq, please use
getCurveServer() instead |
boolean |
getAsServerPlain()
Deprecated.
the naming is inconsistent with jzmq, please use
getPlainServer() instead |
int |
getBacklog()
The ZMQ_BACKLOG option shall retrieve the maximum length of the queue
of outstanding peer connections for the specified socket;
this only applies to connection-oriented transports.
|
boolean |
getConflate()
If in conflate mode, a socket shall keep only one message in its inbound/outbound queue,
this message being the last message received/the last message to be sent.
|
byte[] |
getCurvePublicKey()
Retrieves the current long term public key for the socket in binary format of 32 bytes.
|
byte[] |
getCurveSecretKey()
Retrieves the current long term secret key for the socket in binary format of 32 bytes.
|
boolean |
getCurveServer()
Tells if the socket will act as server for CURVE security.
|
byte[] |
getCurveServerKey()
Retrieves the current server key for the socket in binary format of 32 bytes.
|
boolean |
getDelayAttachOnConnect()
Deprecated.
use
setImmediate(boolean) instead (inverted logic: immediate = true <==> delay attach on connect = false) |
int |
getEvents()
The 'ZMQ_EVENTS' option shall retrieve event flags for the specified socket.
|
SelectableChannel |
getFD()
The 'ZMQ_FD' option shall retrieve file descriptor associated with the 0MQ
socket.
|
int |
getHandshakeIvl()
The ZMQ_HANDSHAKE_IVL option shall retrieve the maximum handshake interval
for the specified socket.
|
byte[] |
getHeartbeatContext()
The ZMQ_HEARTBEAT_CONTEXT option shall set the ping context
of the peer for ZMTP heartbeats.
|
int |
getHeartbeatIvl()
The ZMQ_HEARTBEAT_IVL option shall set the interval
between sending ZMTP heartbeats for the specified socket.
|
int |
getHeartbeatTimeout()
The ZMQ_HEARTBEAT_TIMEOUT option shall set
how long to wait before timing-out a connection
after sending a PING ZMTP command and not receiving any traffic.
|
int |
getHeartbeatTtl()
The ZMQ_HEARTBEAT_TTL option shall set the timeout
on the remote peer for ZMTP heartbeats.
|
int |
getHWM()
Deprecated.
|
byte[] |
getIdentity() |
boolean |
getImmediate()
Retrieve the state of the attach on connect value.
|
boolean |
getIPv4Only()
Deprecated.
use
isIPv6() instead (inverted logic: ipv4 = true <==> ipv6 = false) |
boolean |
getIPv6()
Retrieve the IPv6 option for the socket.
|
String |
getLastEndpoint()
The ZMQ_LAST_ENDPOINT option shall retrieve the last endpoint bound for TCP and IPC transports.
|
int |
getLinger()
The 'ZMQ_LINGER' option shall retrieve the period for pending outbound
messages to linger in memory after closing the socket.
|
long |
getMaxMsgSize()
The option shall retrieve limit for the inbound messages.
|
ZMQ.Socket.Mechanism |
getMechanism()
The ZMQ_MECHANISM option shall retrieve the current security mechanism for the socket.
|
int |
getMsgAllocationHeapThreshold()
Gets the limit threshold where messages of a given size will be allocated using Direct ByteBuffer.
|
long |
getMulticastHops() |
String |
getPlainPassword()
The ZMQ_PLAIN_PASSWORD option shall retrieve the last password
set for the PLAIN security mechanism.
|
boolean |
getPlainServer()
Returns the ZMQ_PLAIN_SERVER option, if any, previously set on the socket.
|
String |
getPlainUsername()
The ZMQ_PLAIN_USERNAME option shall retrieve the last username
set for the PLAIN security mechanism.
|
long |
getRate() |
int |
getRcvHWM()
The ZMQ_RCVHWM option shall return the high water mark for inbound messages on the specified socket.
|
int |
getReceiveBufferSize()
The ZMQ_RCVBUF option shall retrieve the underlying kernel receive buffer size for the specified socket.
|
int |
getReceiveTimeOut()
Retrieve the timeout for recv operation on the socket.
|
int |
getReconnectIVL()
The ZMQ_RECONNECT_IVL option shall retrieve the initial reconnection interval for the specified socket.
|
int |
getReconnectIVLMax()
The ZMQ_RECONNECT_IVL_MAX option shall retrieve the maximum reconnection interval for the specified socket.
|
long |
getRecoveryInterval()
The ZMQ_RECOVERY_IVL option shall retrieve the recovery interval for multicast transports
using the specified socket.
|
boolean |
getReqCorrelate()
Deprecated.
|
boolean |
getReqRelaxed()
Deprecated.
|
SelectorProviderChooser |
getSelectorProviderChooser()
Return the custom
SelectorProvider chooser. |
int |
getSendBufferSize()
The ZMQ_SNDBUF option shall retrieve the underlying kernel transmit buffer size for the specified socket.
|
int |
getSendTimeOut()
Retrieve the timeout for send operation on the socket.
|
int |
getSndHWM()
The ZMQ_SNDHWM option shall return the high water mark for outbound messages on the specified socket.
|
SocketType |
getSocketType()
The 'ZMQ_TYPE option shall retrieve the socket type for the specified
'socket'.
|
String |
getSocksProxy()
The ZMQ_SOCKS_PROXY option shall retrieve the SOCKS5 proxy address in string format.
|
long |
getSwap()
Deprecated.
|
int |
getTCPKeepAlive() |
long |
getTCPKeepAliveCount() |
long |
getTCPKeepAliveIdle() |
long |
getTCPKeepAliveInterval() |
long |
getTCPKeepAliveSetting()
Deprecated.
|
int |
getTos()
Retrieve the IP_TOS option for the socket.
|
int |
getType()
The 'ZMQ_TYPE option shall retrieve the socket type for the specified
'socket'.
|
String |
getZapDomain()
The ZMQ_ZAP_DOMAIN option shall retrieve the last ZAP domain set for the socket.
|
String |
getZAPDomain()
The ZMQ_ZAP_DOMAIN option shall retrieve the last ZAP domain set for the socket.
|
boolean |
hasMulticastLoop()
Deprecated.
|
boolean |
hasReceiveMore()
The 'ZMQ_RCVMORE' option shall return a boolean value indicating if the multi-part
message currently being read from the specified 'socket' has more message parts to
follow.
|
boolean |
isAsServerCurve()
Deprecated.
the naming is inconsistent with jzmq, please use
getCurveServer() instead |
boolean |
isAsServerPlain()
Deprecated.
the naming is inconsistent with jzmq, please use
getPlainServer() instead |
boolean |
isConflate()
If in conflate mode, a socket shall keep only one message in its inbound/outbound queue,
this message being the last message received/the last message to be sent.
|
boolean |
isImmediate()
Retrieve the state of the attach on connect value.
|
boolean |
isIPv6()
Retrieve the IPv6 option for the socket.
|
boolean |
monitor(String addr,
int events)
Start a monitoring socket where events can be received.
|
byte[] |
recv()
Receives a message.
|
int |
recv(byte[] buffer,
int offset,
int len,
int flags)
Receives a message in to a specified buffer.
|
byte[] |
recv(int flags)
Receives a message.
|
int |
recvByteBuffer(ByteBuffer buffer,
int flags)
Receives a message into the specified ByteBuffer.
|
String |
recvStr() |
String |
recvStr(int flags)
Receives a message as a string.
|
java.util.stream.Stream<byte[]> |
recvStream()
Stream of incoming messages
|
java.util.stream.Stream<String> |
recvStrStream()
This API is in DRAFT state and is subject to change at ANY time until declared stable
|
boolean |
send(byte[] data)
Queues a message created from data, so it can be sent.
|
boolean |
send(byte[] data,
int flags)
Queues a message created from data, so it can be sent.
|
boolean |
send(byte[] data,
int off,
int length,
int flags)
Queues a message created from data, so it can be sent.
|
boolean |
send(String data)
Queues a message created from data, so it can be sent.
|
boolean |
send(String data,
int flags)
Queues a message created from data.
|
int |
sendByteBuffer(ByteBuffer data,
int flags)
Queues a message created from data, so it can be sent.
|
boolean |
sendMore(byte[] data)
Queues a multi-part message created from data, so it can be sent.
|
boolean |
sendMore(String data)
Queues a multi-part message created from data, so it can be sent.
|
boolean |
setAffinity(long value)
Get the Affinity.
|
boolean |
setAsServerCurve(boolean server)
Deprecated.
the naming is inconsistent with jzmq, please use
setCurveServer(boolean) instead |
boolean |
setAsServerPlain(boolean server)
Deprecated.
the naming is inconsistent with jzmq, please use
setPlainServer(boolean) instead |
boolean |
setBacklog(int value)
The ZMQ_BACKLOG option shall set the maximum length
of the queue of outstanding peer connections for the specified socket;
this only applies to connection-oriented transports.
|
boolean |
setBacklog(long value)
Deprecated.
this option uses integer range, use
setBacklog(int) instead. |
boolean |
setConflate(boolean conflate)
If set, a socket shall keep only one message in its inbound/outbound queue,
this message being the last message received/the last message to be sent.
|
boolean |
setConnectRid(byte[] rid)
The ZMQ_CONNECT_RID option sets the peer id of the next host connected via the connect() call,
and immediately readies that connection for data transfer with the named id.
|
boolean |
setConnectRid(String rid)
The ZMQ_CONNECT_RID option sets the peer id of the next host connected via the connect() call,
and immediately readies that connection for data transfer with the named id.
|
boolean |
setCurvePublicKey(byte[] key)
Sets the socket's long term public key.
|
boolean |
setCurveSecretKey(byte[] key)
Sets the socket's long term secret key.
|
boolean |
setCurveServer(boolean server)
Defines whether the socket will act as server for CURVE security, see zmq_curve(7).
|
boolean |
setCurveServerKey(byte[] key)
Sets the socket's long term server key.
|
boolean |
setDecoder(Class<? extends IDecoder> cls)
Deprecated.
|
boolean |
setDelayAttachOnConnect(boolean value)
Deprecated.
use
setImmediate(boolean) instead (warning, the boolean is inverted) |
boolean |
setEncoder(Class<? extends IEncoder> cls)
Deprecated.
|
boolean |
setHandshakeIvl(int maxHandshakeIvl)
The ZMQ_HANDSHAKE_IVL option shall set the maximum handshake interval for the specified socket.
|
boolean |
setHeartbeatContext(byte[] pingContext)
The ZMQ_HEARTBEAT_CONTEXT option shall set the ping context
of the peer for ZMTP heartbeats.
|
boolean |
setHeartbeatIvl(int heartbeatIvl)
The ZMQ_HEARTBEAT_IVL option shall set the interval
between sending ZMTP heartbeats for the specified socket.
|
boolean |
setHeartbeatTimeout(int heartbeatTimeout)
The ZMQ_HEARTBEAT_TIMEOUT option shall set
how long to wait before timing-out a connection
after sending a PING ZMTP command and not receiving any traffic.
|
boolean |
setHeartbeatTtl(int heartbeatTtl)
The ZMQ_HEARTBEAT_TTL option shall set the timeout
on the remote peer for ZMTP heartbeats.
|
boolean |
setHWM(int hwm)
The 'ZMQ_HWM' option shall set the high water mark for the specified 'socket'.
|
boolean |
setHWM(long hwm)
Deprecated.
this option uses integer range, use
setHWM(int) instead |
boolean |
setIdentity(byte[] identity)
The 'ZMQ_IDENTITY' option shall set the identity of the specified 'socket'.
|
boolean |
setImmediate(boolean value)
Accept messages immediately or only when connections are made
|
boolean |
setIPv4Only(boolean v4only)
Deprecated.
use
setIPv6(boolean) instead (inverted logic: ipv4 = true <==> ipv6 = false) |
boolean |
setIPv6(boolean v6)
Set the IPv6 option for the socket.
|
boolean |
setLinger(int value)
The ZMQ_LINGER option shall set the linger period for the specified socket.
|
boolean |
setLinger(long value)
Deprecated.
the linger option has only integer range, use
setLinger(int) instead |
boolean |
setMaxMsgSize(long value)
Limits the size of the inbound message.
|
boolean |
setMsgAllocationHeapThreshold(int threshold)
Sets the limit threshold where messages of a given size will be allocated using Direct ByteBuffer.
|
boolean |
setMsgAllocator(MsgAllocator allocator)
Sets a custom message allocator.
|
boolean |
setMulticastHops(long value)
Sets the time-to-live field in every multicast packet sent from this socket.
|
boolean |
setMulticastLoop(boolean multicastLoop)
Deprecated.
|
boolean |
setPlainPassword(byte[] password)
Sets the password for outgoing connections over TCP or IPC.
|
boolean |
setPlainPassword(String password)
Sets the password for outgoing connections over TCP or IPC.
|
boolean |
setPlainServer(boolean server)
Defines whether the socket will act as server for PLAIN security, see zmq_plain(7).
|
boolean |
setPlainUsername(byte[] username)
Sets the username for outgoing connections over TCP or IPC.
|
boolean |
setPlainUsername(String username)
Sets the username for outgoing connections over TCP or IPC.
|
boolean |
setProbeRouter(boolean probe)
When set to true, the socket will automatically send
an empty message when a new connection is made or accepted.
|
boolean |
setRate(long value)
The 'ZMQ_RATE' option shall set the maximum send or receive data rate for multicast
transports such as in the man page of zmq_pgm[7] using the specified 'socket'.
|
boolean |
setRcvHWM(int value)
The ZMQ_RCVHWM option shall set the high water mark for inbound messages on the specified socket.
|
boolean |
setRcvHWM(long value)
Deprecated.
this option uses integer range, use
setRcvHWM(int) instead |
boolean |
setReceiveBufferSize(int value)
The 'ZMQ_RCVBUF' option shall set the underlying kernel receive buffer size for the
'socket' to the specified size in bytes.
|
boolean |
setReceiveBufferSize(long value)
Deprecated.
this option uses integer range, use
setReceiveBufferSize(int) instead |
boolean |
setReceiveTimeOut(int value)
Sets the timeout for receive operation on the socket.
|
boolean |
setReconnectIVL(int value)
The ZMQ_RECONNECT_IVL option shall set the initial reconnection interval for the specified socket.
|
boolean |
setReconnectIVL(long value)
Deprecated.
reconnect interval option uses integer range, use
setReconnectIVL(int) instead |
boolean |
setReconnectIVLMax(int value)
The ZMQ_RECONNECT_IVL_MAX option shall set the maximum reconnection interval for the specified socket.
|
boolean |
setReconnectIVLMax(long value)
Deprecated.
this option uses integer range, use
setReconnectIVLMax(int) instead |
boolean |
setRecoveryInterval(long value)
The 'ZMQ_RECOVERY_IVL' option shall set the recovery interval for multicast transports
using the specified 'socket'.
|
boolean |
setReqCorrelate(boolean correlate)
The default behavior of REQ sockets is to rely on the ordering of messages
to match requests and responses and that is usually sufficient.
|
boolean |
setReqRelaxed(boolean relaxed)
By default, a REQ socket does not allow initiating a new request with zmq_send(3)
until the reply to the previous one has been received.
|
boolean |
setRouterHandover(boolean handover)
If two clients use the same identity when connecting to a ROUTER,
the results shall depend on the ZMQ_ROUTER_HANDOVER option setting.
|
boolean |
setRouterMandatory(boolean mandatory)
Sets the ROUTER socket behavior when an unroutable message is encountered.
|
boolean |
setRouterRaw(boolean raw)
Sets the raw mode on the ROUTER, when set to true.
|
boolean |
setSelectorChooser(SelectorProviderChooser chooser)
Set a custom
SelectorProvider chooser. |
boolean |
setSendBufferSize(int value)
The 'ZMQ_SNDBUF' option shall set the underlying kernel transmit buffer size for the
'socket' to the specified size in bytes.
|
boolean |
setSendBufferSize(long value)
Deprecated.
this option uses integer range, use
setSendBufferSize(int) instead |
boolean |
setSendTimeOut(int value)
Sets the timeout for send operation on the socket.
|
boolean |
setSndHWM(int value)
The ZMQ_SNDHWM option shall set the high water mark for outbound messages on the specified socket.
|
boolean |
setSndHWM(long value)
Deprecated.
this option uses integer range, use
setSndHWM(int) instead |
boolean |
setSocksProxy(byte[] proxy)
Sets the SOCKS5 proxy address that shall be used by the socket for the TCP connection(s).
|
boolean |
setSocksProxy(String proxy)
Sets the SOCKS5 proxy address that shall be used by the socket for the TCP connection(s).
|
boolean |
setSwap(long value)
Deprecated.
|
boolean |
setTCPKeepAlive(int optVal)
Override SO_KEEPALIVE socket option (where supported by OS) to enable keep-alive packets for a socket
connection.
|
boolean |
setTCPKeepAlive(long value)
Deprecated.
|
boolean |
setTCPKeepAliveCount(long value)
Override TCP_KEEPCNT socket option (where supported by OS).
|
boolean |
setTCPKeepAliveIdle(long value)
Override TCP_KEEPCNT (or TCP_KEEPALIVE on some OS) socket option (where supported by OS).
|
boolean |
setTCPKeepAliveInterval(long value)
Override TCP_KEEPINTVL socket option (where supported by OS).
|
boolean |
setTos(int value)
Sets the ToS fields (Differentiated services (DS)
and Explicit Congestion Notification (ECN) field of the IP header.
|
boolean |
setXpubNoDrop(boolean noDrop)
Sets the XPUB socket behaviour to return error EAGAIN if SENDHWM is reached and the message could not be send.
|
boolean |
setXpubVerbose(boolean verbose)
Sets the XPUB socket behavior on new subscriptions and unsubscriptions.
|
boolean |
setZapDomain(byte[] domain)
Sets the domain for ZAP (ZMQ RFC 27) authentication.
|
boolean |
setZAPDomain(byte[] domain)
Sets the domain for ZAP (ZMQ RFC 27) authentication.
|
boolean |
setZapDomain(String domain)
Sets the domain for ZAP (ZMQ RFC 27) authentication.
|
boolean |
setZAPDomain(String domain)
Sets the domain for ZAP (ZMQ RFC 27) authentication.
|
boolean |
subscribe(byte[] topic)
The 'ZMQ_SUBSCRIBE' option shall establish a new message filter on a 'ZMQ_SUB' socket.
|
boolean |
subscribe(String topic)
The 'ZMQ_SUBSCRIBE' option shall establish a new message filter on a 'ZMQ_SUB' socket.
|
String |
toString() |
boolean |
unbind(String addr)
Stop accepting connections on a socket.
|
boolean |
unsubscribe(byte[] topic)
The 'ZMQ_UNSUBSCRIBE' option shall remove an existing message filter on a 'ZMQ_SUB'
socket.
|
boolean |
unsubscribe(String topic)
The 'ZMQ_UNSUBSCRIBE' option shall remove an existing message filter on a 'ZMQ_SUB'
socket.
|
protected Socket(ZMQ.Context context, SocketType type)
context
- a 0MQ context previously created.type
- the socket type.@Deprecated protected Socket(ZMQ.Context context, int type)
Socket#Socket(Context, SocketType)
context
- a 0MQ context previously created.type
- the socket type.protected Socket(SocketBase base)
public SocketBase base()
public void close()
close
in interface Closeable
close
in interface AutoCloseable
public int getType()
public SocketType getSocketType()
public int getLinger()
setLinger(int)
@Deprecated public boolean setLinger(long value)
setLinger(int)
insteadvalue
- the linger period in milliseconds.getLinger()
public boolean setLinger(int value)
value
- the linger period in milliseconds.getLinger()
public int getReconnectIVL()
CAUTION: The reconnection interval may be randomized by ØMQ to prevent reconnection storms in topologies with a large number of peers per socket.
setReconnectIVL(int)
@Deprecated public boolean setReconnectIVL(long value)
setReconnectIVL(int)
insteadgetReconnectIVL()
public boolean setReconnectIVL(int value)
getReconnectIVL()
public int getBacklog()
setBacklog(int)
@Deprecated public boolean setBacklog(long value)
setBacklog(int)
instead.value
- the maximum length of the queue of outstanding peer connections.getBacklog()
public boolean setBacklog(int value)
value
- the maximum length of the queue of outstanding peer connections.getBacklog()
public int getHandshakeIvl()
setHandshakeIvl(int)
public int getHeartbeatIvl()
public int getHeartbeatTimeout()
public int getHeartbeatTtl()
public byte[] getHeartbeatContext()
This API is in DRAFT state and is subject to change at ANY time until declared stable.
If this option is set, every ping message sent for heartbeat will contain this context.
public boolean setHandshakeIvl(int maxHandshakeIvl)
maxHandshakeIvl
- the maximum handshake intervalgetHandshakeIvl()
public boolean setHeartbeatIvl(int heartbeatIvl)
heartbeatIvl
- heartbeat interval in millisecondspublic boolean setHeartbeatTimeout(int heartbeatTimeout)
heartbeatTimeout
- heartbeat timeout in millisecondspublic boolean setHeartbeatTtl(int heartbeatTtl)
heartbeatTtl
- heartbeat time-to-live in millisecondspublic boolean setHeartbeatContext(byte[] pingContext)
This API is in DRAFT state and is subject to change at ANY time until declared stable.
If this option is set, every ping message sent for heartbeat will contain this context.
pingContext
- the context to be sent with ping messages.public int getTos()
setTos(int)
public boolean setTos(int value)
getTos()
public int getReconnectIVLMax()
setReconnectIVLMax(int)
@Deprecated public boolean setReconnectIVLMax(long value)
setReconnectIVLMax(int)
insteadgetReconnectIVLMax()
public boolean setReconnectIVLMax(int value)
getReconnectIVLMax()
public long getMaxMsgSize()
setMaxMsgSize(long)
public boolean setMaxMsgSize(long value)
getMaxMsgSize()
public int getSndHWM()
setSndHWM(int)
@Deprecated public boolean setSndHWM(long value)
setSndHWM(int)
insteadCAUTION: ØMQ does not guarantee that the socket will accept as many as ZMQ_SNDHWM messages, and the actual limit may be as much as 60-70% lower depending on the flow of messages on the socket.
getSndHWM()
public boolean setSndHWM(int value)
CAUTION: ØMQ does not guarantee that the socket will accept as many as ZMQ_SNDHWM messages, and the actual limit may be as much as 60-70% lower depending on the flow of messages on the socket.
value
- getSndHWM()
public int getRcvHWM()
setRcvHWM(int)
@Deprecated public boolean setRcvHWM(long value)
setRcvHWM(int)
insteadgetRcvHWM()
public boolean setRcvHWM(int value)
value
- getRcvHWM()
@Deprecated public int getHWM()
setHWM(int)
@Deprecated public boolean setHWM(long hwm)
setHWM(int)
insteadIf this limit has been reached the socket shall enter an exceptional state and depending on the socket type, 0MQ shall take appropriate action such as blocking or dropping sent messages. Refer to the individual socket descriptions in the man page of zmq_socket[3] for details on the exact action taken for each socket type.
hwm
- the number of messages to queue.public boolean setHWM(int hwm)
If this limit has been reached the socket shall enter an exceptional state and depending on the socket type, 0MQ shall take appropriate action such as blocking or dropping sent messages. Refer to the individual socket descriptions in the man page of zmq_socket[3] for details on the exact action taken for each socket type.
hwm
- the number of messages to queue.@Deprecated public long getSwap()
setSwap(long)
public boolean setConflate(boolean conflate)
conflate
- true to keep only one message, false for standard behaviour.isConflate()
public boolean isConflate()
setConflate(boolean)
public boolean getConflate()
setConflate(boolean)
@Deprecated public boolean setSwap(long value)
value
- The value of 'ZMQ_SWAP' defines the maximum size of the swap space in bytes.public long getAffinity()
setAffinity(long)
public boolean setAffinity(long value)
Affinity determines which threads from the 0MQ I/O thread pool associated with the socket's _context_ shall handle newly created connections. A value of zero specifies no affinity, meaning that work shall be distributed fairly among all 0MQ I/O threads in the thread pool. For non-zero values, the lowest bit corresponds to thread 1, second lowest bit to thread 2 and so on. For example, a value of 3 specifies that subsequent connections on 'socket' shall be handled exclusively by I/O threads 1 and 2.
See also in the man page of init[3] for details on allocating the number of I/O threads for a specific _context_.
value
- the io_thread affinity.public byte[] getIdentity()
setIdentity(byte[])
public boolean setIdentity(byte[] identity)
If the socket has no identity, each run of an application is completely separate from other runs. However, with identity set the socket shall re-use any existing 0MQ infrastructure configured by the previous run(s). Thus the application may receive messages that were sent in the meantime, _message queue_ limits shall be shared with previous run(s) and so on.
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.
identity
- public long getRate()
setRate(long)
public boolean setRate(long value)
value
- maximum send or receive data rate for multicast, default 100public long getRecoveryInterval()
setRecoveryInterval(long)
public boolean setRecoveryInterval(long value)
CAUTION: Exercise care when setting large recovery intervals as the data needed for recovery will be held in memory. For example, a 1 minute recovery interval at a data rate of 1Gbps requires a 7GB in-memory buffer. {Purpose of this Method}
value
- recovery interval for multicast in milliseconds, default 10000getRecoveryInterval()
public boolean setReqCorrelate(boolean correlate)
correlate
- Whether to enable outgoing request ids.getReqCorrelate()
@Deprecated public boolean getReqCorrelate()
setReqCorrelate(boolean)
public boolean setReqRelaxed(boolean relaxed)
relaxed
- getReqRelaxed()
@Deprecated public boolean getReqRelaxed()
setReqRelaxed(boolean)
@Deprecated public boolean hasMulticastLoop()
setMulticastLoop(boolean)
@Deprecated public boolean setMulticastLoop(boolean multicastLoop)
multicastLoop
- public long getMulticastHops()
setMulticastHops(long)
public boolean setMulticastHops(long value)
value
- time-to-live field in every multicast packet, default 1public int getReceiveTimeOut()
setReceiveTimeOut(int)
public boolean setReceiveTimeOut(int value)
value
- Timeout for receive operation in milliseconds. Default -1 (infinite)getReceiveTimeOut()
public int getSendTimeOut()
setSendTimeOut(int)
public boolean setSendTimeOut(int value)
value
- Timeout for send operation in milliseconds. Default -1 (infinite)getSendTimeOut()
@Deprecated public boolean setTCPKeepAlive(long value)
value
- The value of 'ZMQ_TCP_KEEPALIVE' to turn TCP keepalives on (1) or off (0).@Deprecated public long getTCPKeepAliveSetting()
setTCPKeepAlive(long)
public boolean setTCPKeepAliveCount(long value)
value
- The value of 'ZMQ_TCP_KEEPALIVE_CNT' defines the number of keepalives before death.public long getTCPKeepAliveCount()
setTCPKeepAliveCount(long)
public boolean setTCPKeepAliveInterval(long value)
value
- The value of 'ZMQ_TCP_KEEPALIVE_INTVL' defines the interval between keepalives. Unit is OS
dependent.public long getTCPKeepAliveInterval()
setTCPKeepAliveInterval(long)
public boolean setTCPKeepAliveIdle(long value)
value
- The value of 'ZMQ_TCP_KEEPALIVE_IDLE' defines the interval between the last data packet sent
over the socket and the first keepalive probe. Unit is OS dependent.public long getTCPKeepAliveIdle()
setTCPKeepAliveIdle(long)
public int getSendBufferSize()
setSendBufferSize(int)
@Deprecated public boolean setSendBufferSize(long value)
setSendBufferSize(int)
insteadvalue
- underlying kernel transmit buffer size for the 'socket' in bytes
A value of zero means leave the OS default unchanged.getSendBufferSize()
public boolean setSendBufferSize(int value)
value
- underlying kernel transmit buffer size for the 'socket' in bytes
A value of zero means leave the OS default unchanged.getSendBufferSize()
public int getReceiveBufferSize()
setReceiveBufferSize(int)
@Deprecated public boolean setReceiveBufferSize(long value)
setReceiveBufferSize(int)
insteadvalue
- Underlying kernel receive buffer size for the 'socket' in bytes.
A value of zero means leave the OS default unchanged.getReceiveBufferSize()
public boolean setReceiveBufferSize(int value)
value
- Underlying kernel receive buffer size for the 'socket' in bytes.
A value of zero means leave the OS default unchanged.getReceiveBufferSize()
public boolean hasReceiveMore()
public SelectableChannel getFD()
public int getEvents()
public boolean subscribe(byte[] topic)
An empty 'option_value' of length zero shall subscribe to all incoming messages. A non-empty 'option_value' shall subscribe to all messages beginning with the specified prefix. Mutiple filters may be attached to a single 'ZMQ_SUB' socket, in which case a message shall be accepted if it matches at least one filter.
topic
- public boolean subscribe(String topic)
An empty 'option_value' of length zero shall subscribe to all incoming messages. A non-empty 'option_value' shall subscribe to all messages beginning with the specified prefix. Mutiple filters may be attached to a single 'ZMQ_SUB' socket, in which case a message shall be accepted if it matches at least one filter.
topic
- public boolean unsubscribe(byte[] topic)
topic
- public boolean unsubscribe(String topic)
topic
- @Deprecated public boolean setEncoder(Class<? extends IEncoder> cls)
cls
- @Deprecated public boolean setDecoder(Class<? extends IDecoder> cls)
cls
- public boolean setMsgAllocationHeapThreshold(int threshold)
threshold
- the threshold to set for the size limit of messages. 0 or negative to disable this system.public int getMsgAllocationHeapThreshold()
public boolean setMsgAllocator(MsgAllocator allocator)
allocator
- the custom allocator.public boolean setSelectorChooser(SelectorProviderChooser chooser)
SelectorProvider
chooser.chooser,
- the custom chooser.public SelectorProviderChooser getSelectorProviderChooser()
SelectorProvider
chooser.SelectorProvider
chooser.public boolean setConnectRid(String rid)
rid
- the peer id of the next host.public boolean setConnectRid(byte[] rid)
rid
- the peer id of the next host.public boolean setRouterRaw(boolean raw)
raw
- true to set the raw mode on the ROUTER.public boolean setProbeRouter(boolean probe)
probe
- true to send automatically an empty message when a new connection is made or accepted.public boolean setRouterMandatory(boolean mandatory)
mandatory
- A value of false is the default and discards the message silently when it cannot be routed.
A value of true returns an EHOSTUNREACH error code if the message cannot be routed.public boolean setRouterHandover(boolean handover)
handover
- A value of false, (default) the ROUTER socket shall reject clients trying to connect with an already-used identity
A value of true, the ROUTER socket shall hand-over the connection to the new client and disconnect the existing onepublic boolean setXpubVerbose(boolean verbose)
verbose
- A value of false is the default and passes only new subscription messages to upstream.
A value of true passes all subscription messages upstream.public boolean setXpubNoDrop(boolean noDrop)
noDrop
- @Deprecated public boolean getIPv4Only()
isIPv6()
instead (inverted logic: ipv4 = true <==> ipv6 = false)(boolean)
public boolean isIPv6()
(boolean)
public boolean getIPv6()
(boolean)
@Deprecated public boolean setIPv4Only(boolean v4only)
setIPv6(boolean)
instead (inverted logic: ipv4 = true <==> ipv6 = false)v4only
- A value of true will use IPv4 sockets, while the value of false will use IPv6 socketspublic boolean setIPv6(boolean v6)
v6
- A value of true will use IPv6 sockets, while the value of false will use IPv4 socketsisIPv6()
public int getTCPKeepAlive()
setTCPKeepAlive(int)
public boolean setTCPKeepAlive(int optVal)
optVal
- The value of 'ZMQ_TCP_KEEPALIVE' to turn TCP keepalives on (1) or off (0).@Deprecated public boolean getDelayAttachOnConnect()
setImmediate(boolean)
instead (inverted logic: immediate = true <==> delay attach on connect = false)setDelayAttachOnConnect(boolean)
@Deprecated public boolean setDelayAttachOnConnect(boolean value)
setImmediate(boolean)
instead (warning, the boolean is inverted)If set to true, will delay the attachment of a pipe on connect until the underlying connection has completed. This will cause the socket to block if there are no other connections, but will prevent queues from filling on pipes awaiting connection
value
- The value of 'ZMQ_DELAY_ATTACH_ON_CONNECT'. Default false.public boolean isImmediate()
setImmediate(boolean)
public boolean getImmediate()
setImmediate(boolean)
public boolean setImmediate(boolean value)
By default queues will fill on outgoing connections even if the connection has not completed. This can lead to "lost" messages on sockets with round-robin routing (REQ, PUSH, DEALER). If this option is set to false, messages shall be queued only to completed connections. This will cause the socket to block if there are no other connections, but will prevent queues from filling on pipes awaiting connection.
value
- The value of 'ZMQ_IMMEDIATE'. Default true.isImmediate()
public boolean setSocksProxy(String proxy)
proxy
- getSocksProxy()
public boolean setSocksProxy(byte[] proxy)
proxy
- getSocksProxy()
public String getSocksProxy()
setSocksProxy(byte[])
public String getLastEndpoint()
public boolean setZapDomain(String domain)
domain
- the domain of ZAP authenticationgetZapDomain()
public boolean setZapDomain(byte[] domain)
domain
- the domain of ZAP authenticationgetZapDomain()
public String getZapDomain()
setZapDomain(String)
public boolean setZAPDomain(String domain)
domain
- the domain of ZAP authenticationgetZapDomain()
public boolean setZAPDomain(byte[] domain)
domain
- the domain of ZAP authenticationgetZapDomain()
public String getZAPDomain()
setZapDomain(String)
@Deprecated public boolean setAsServerPlain(boolean server)
setPlainServer(boolean)
insteadserver
- true if the role of the socket should be server for PLAIN security.isAsServerPlain()
public boolean setPlainServer(boolean server)
server
- true if the role of the socket should be server for PLAIN security.isAsServerPlain()
@Deprecated public boolean isAsServerPlain()
getPlainServer()
insteadsetAsServerPlain(boolean)
@Deprecated public boolean getAsServerPlain()
getPlainServer()
insteadsetAsServerPlain(boolean)
public boolean getPlainServer()
setAsServerPlain(boolean)
public boolean setPlainUsername(String username)
username
- the username to set.public boolean setPlainPassword(String password)
password
- the password to set.public boolean setPlainUsername(byte[] username)
username
- the username to set.public boolean setPlainPassword(byte[] password)
password
- the password to set.public String getPlainUsername()
public String getPlainPassword()
@Deprecated public boolean setAsServerCurve(boolean server)
setCurveServer(boolean)
insteadserver
- true if the role of the socket should be server for CURVE mechanismisAsServerCurve()
public boolean setCurveServer(boolean server)
server
- true if the role of the socket should be server for CURVE mechanismisAsServerCurve()
@Deprecated public boolean isAsServerCurve()
getCurveServer()
insteadsetAsServerCurve(boolean)
public boolean getCurveServer()
setAsServerCurve(boolean)
@Deprecated public boolean getAsServerCurve()
getCurveServer()
insteadsetAsServerCurve(boolean)
public boolean setCurvePublicKey(byte[] key)
Curve.keypair()
or Curve.keypairZ85()
.key
- the curve public keygetCurvePublicKey()
public boolean setCurveServerKey(byte[] key)
Curve.keypair()
or Curve.keypairZ85()
.key
- the curve server keygetCurveServerKey()
public boolean setCurveSecretKey(byte[] key)
Curve.keypair()
or Curve.keypairZ85()
.key
- the curve secret keygetCurveSecretKey()
public byte[] getCurvePublicKey()
setCurvePublicKey(byte[])
public byte[] getCurveServerKey()
setCurveServerKey(byte[])
public byte[] getCurveSecretKey()
setCurveSecretKey(byte[])
public ZMQ.Socket.Mechanism getMechanism()
public boolean bind(String addr)
addr
- the endpoint to bind to.public int bindToRandomPort(String addr)
addr
- the endpoint to bind to.public int bindToRandomPort(String addr, int min, int max)
addr
- the endpoint to bind to.min
- The minimum port in the range of ports to try.max
- The maximum port in the range of ports to try.public boolean connect(String addr)
bind(String)
before calling connect().
bind(String)
alone, the socket enters a mute state
in which the socket blocks or drops messages according to the socket type.
addr
- the endpoint to connect to.public boolean disconnect(String addr)
addr
- the endpoint to disconnect from.public boolean unbind(String addr)
addr
- the endpoint to unbind from.public boolean send(String data)
data
- the data to send. The data is either a single-part message by itself,
or the last part of a multi-part message.public boolean sendMore(String data)
data
- the data to send. further message parts are to follow.public boolean send(String data, int flags)
data
- the data to send.flags
- a combination (with + or |) of the flags defined below:
DONTWAIT
:
For socket types (DEALER
, PUSH
)
that block when there are no available peers (or all peers have full high-water mark),
specifies that the operation should be performed in non-blocking mode.
If the message cannot be queued on the socket, the method shall fail with errno set to EAGAIN.SNDMORE
:
Specifies that the message being sent is a multi-part message,
and that further message parts are to follow.public boolean send(byte[] data)
data
- the data to send. The data is either a single-part message by itself,
or the last part of a multi-part message.public boolean sendMore(byte[] data)
data
- the data to send. further message parts are to follow.public boolean send(byte[] data, int flags)
data
- the data to send.flags
- a combination (with + or |) of the flags defined below:
DONTWAIT
:
For socket types (DEALER
, PUSH
)
that block when there are no available peers (or all peers have full high-water mark),
specifies that the operation should be performed in non-blocking mode.
If the message cannot be queued on the socket, the method shall fail with errno set to EAGAIN.SNDMORE
:
Specifies that the message being sent is a multi-part message,
and that further message parts are to follow.public boolean send(byte[] data, int off, int length, int flags)
data
- the data to send.off
- the index of the first byte to be sent.length
- the number of bytes to be sent.flags
- a combination (with + or |) of the flags defined below:
DONTWAIT
:
For socket types (DEALER
, PUSH
)
that block when there are no available peers (or all peers have full high-water mark),
specifies that the operation should be performed in non-blocking mode.
If the message cannot be queued on the socket, the method shall fail with errno set to EAGAIN.SNDMORE
:
Specifies that the message being sent is a multi-part message,
and that further message parts are to follow.public int sendByteBuffer(ByteBuffer data, int flags)
data
- ByteBuffer payloadflags
- a combination (with + or |) of the flags defined below:
DONTWAIT
:
For socket types (DEALER
, PUSH
)
that block when there are no available peers (or all peers have full high-water mark),
specifies that the operation should be performed in non-blocking mode.
If the message cannot be queued on the socket, the method shall fail with errno set to EAGAIN.SNDMORE
:
Specifies that the message being sent is a multi-part message,
and that further message parts are to follow.public byte[] recv()
public java.util.stream.Stream<byte[]> recvStream()
This API is in DRAFT state and is subject to change at ANY time until declared stable
public byte[] recv(int flags)
flags
- either:
DONTWAIT
:
Specifies that the operation should be performed in non-blocking mode.
If there are no messages available on the specified socket,
the method shall fail with errno set to EAGAIN and return null.setReceiveTimeOut(int)
expires.public int recv(byte[] buffer, int offset, int len, int flags)
buffer
- byte[] to copy zmq message payload in to.offset
- offset in buffer to write datalen
- max bytes to write to buffer.
If len is smaller than the incoming message size,
the message will be truncated.flags
- either:
DONTWAIT
:
Specifies that the operation should be performed in non-blocking mode.
If there are no messages available on the specified socket,
the method shall fail with errno set to EAGAIN and return null.setReceiveTimeOut(int)
expires.public int recvByteBuffer(ByteBuffer buffer, int flags)
buffer
- the buffer to copy the zmq message payload intoflags
- either:
DONTWAIT
:
Specifies that the operation should be performed in non-blocking mode.
If there are no messages available on the specified socket,
the method shall fail with errno set to EAGAIN and return null.setReceiveTimeOut(int)
expires.public String recvStr()
public java.util.stream.Stream<String> recvStrStream()
public String recvStr(int flags)
flags
- either:
DONTWAIT
:
Specifies that the operation should be performed in non-blocking mode.
If there are no messages available on the specified socket,
the method shall fail with errno set to EAGAIN and return null.setReceiveTimeOut(int)
expires.public boolean monitor(String addr, int events)
Lets an application thread track socket events (like connects) on a ZeroMQ socket.
Each call to this method creates a ZMQ.PAIR
socket and binds that to the specified inproc:// endpoint.
To collect the socket events, you must create your own PAIR socket, and connect that to the endpoint.
Supports only connection-oriented transports, that is, TCP, IPC.
addr
- the endpoint to receive events from. (must be inproc transport)events
- the events of interest. A bitmask of the socket events you wish to monitor. To monitor all events, use the event value ZMQ.EVENT_ALL
.ZMQException
public int errno()
Copyright © 2019. All rights reserved.