org.zeromq
Class ZMQ.Socket

java.lang.Object
  extended by org.zeromq.ZMQ.Socket
Enclosing class:
ZMQ

public static class ZMQ.Socket
extends Object

Inner class: Socket.


Constructor Summary
protected ZMQ.Socket(ZMQ.Context context, int type)
          Class constructor.
 
Method Summary
 void 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_port)
          Bind to network interface to a random port.
 int bindToRandomPort(String addr, int min_port, int max_port)
          Bind to network interface to a random port.
 int bindToRandomPort(String addr, int min_port, int max_port, int max_tries)
          Bind to network interface to a random port.
 void close()
          This is an explicit "destructor".
 void connect(String addr)
          Connect to remote application.
protected  void construct(ZMQ.Context ctx, int type)
          Initialize the JNI interface
 void disconnect(String addr)
          Disconnect from a remote application.
protected  void finalize()
          Free all resources used by JNI interface.
 long getAffinity()
           
 long getBacklog()
           
protected  byte[] getBytesSockopt(int option)
          Get the socket option value, as a byte array.
 long getEvents()
          The 'ZMQ_EVENTS' option shall retrieve event flags for the specified socket.
 long getFD()
          The 'ZMQ_FD' option shall retrieve file descriptor associated with the 0MQ socket.
 long getHWM()
           
 byte[] getIdentity()
           
 boolean getIPv4Only()
           
 long getLinger()
           
protected  long getLongSockopt(int option)
          Get the socket option value, as a long.
 long getMaxMsgSize()
           
 long getMulticastHops()
           
 long getRate()
           
 long getRcvHWM()
           
 long getReceiveBufferSize()
           
 int getReceiveTimeOut()
           
 long getReconnectIVL()
           
 long getReconnectIVLMax()
           
 long getRecoveryInterval()
           
 long getSendBufferSize()
           
 int getSendTimeOut()
           
 long getSndHWM()
           
 long getSwap()
           
 long getTCPKeepAliveCount()
           
 long getTCPKeepAliveIdle()
           
 long getTCPKeepAliveInterval()
           
 long getTCPKeepAliveSetting()
           
 int getType()
          The 'ZMQ_TYPE option shall retrieve the socket type for the specified 'socket'.
 boolean hasMulticastLoop()
           
 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.
 byte[] recv()
          Receive a message.
 int recv(byte[] buffer, int offset, int len, int flags)
          Receive a message in to a specified buffer.
 byte[] recv(int flags)
          Receive a message.
 String recvStr()
          Receive a message as a String.
 String recvStr(int flags)
          Receive a message as a String.
 int recvZeroCopy(ByteBuffer buffer, int len, int flags)
          Zero copy recv
 boolean send(byte[] msg, int flags)
          Send a message.
 boolean send(byte[] msg, int offset, int flags)
          Send a message.
 boolean send(byte[] msg, int offset, int len, int flags)
           
 boolean send(String msg)
          Send a String.
 boolean send(String msg, int flags)
          Send a String.
 boolean sendMore(String msg)
          Send a String.
 boolean sendZeroCopy(ByteBuffer buffer, int len, int flags)
          Perform a zero copy send.
 void setAffinity(long affinity)
          Get the Affinity.
 void setBacklog(long backlog)
           
protected  void setBytesSockopt(int option, byte[] optval)
          Set the socket option value, given as a byte array.
 void setHWM(long hwm)
          The 'ZMQ_HWM' option shall set the high water mark for the specified 'socket'.
 void setIdentity(byte[] identity)
          The 'ZMQ_IDENTITY' option shall set the identity of the specified 'socket'.
 void setIPv4Only(boolean v4only)
          The 'ZMQ_IPV4ONLY' option shall set the underlying native socket type.
 void setLinger(long linger)
          The 'ZMQ_LINGER' option shall retrieve the period for pending outbound messages to linger in memory after closing the socket.
protected  void setLongSockopt(int option, long optval)
          Set the socket option value, given as a long.
 void setMaxMsgSize(long maxMsgSize)
           
 void setMulticastHops(long mcast_hops)
          Sets the time-to-live field in every multicast packet sent from this socket.
 void setMulticastLoop(boolean mcast_loop)
          The 'ZMQ_MCAST_LOOP' option shall control whether data sent via multicast transports using the specified 'socket' can also be received by the sending host via loopback.
 void setRate(long rate)
          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'.
 void setRcvHWM(long rcvHWM)
           
 void setReceiveBufferSize(long rcvbuf)
          The 'ZMQ_RCVBUF' option shall set the underlying kernel receive buffer size for the 'socket' to the specified size in bytes.
 void setReceiveTimeOut(int timeout)
          Sets the timeout for receive operation on the socket.
 void setReconnectIVL(long reconnectIVL)
           
 void setReconnectIVLMax(long reconnectIVLMax)
           
 void setRecoveryInterval(long recovery_ivl)
          The 'ZMQ_RECOVERY_IVL' option shall set the recovery interval for multicast transports using the specified 'socket'.
 void setRouterMandatory(boolean mandatory)
          Sets the ROUTER socket behavior when an unroutable message is encountered.
 void setSendBufferSize(long sndbuf)
          The 'ZMQ_SNDBUF' option shall set the underlying kernel transmit buffer size for the 'socket' to the specified size in bytes.
 void setSendTimeOut(int timeout)
          Sets the timeout for send operation on the socket.
 void setSndHWM(long sndHWM)
           
 void setSwap(long swap)
          Get the Swap.
 void setTCPKeepAlive(long optVal)
          Override SO_KEEPALIVE socket option (where supported by OS) to enable keep-alive packets for a socket connection.
 void setTCPKeepAliveCount(long optVal)
          Override TCP_KEEPCNT socket option (where supported by OS).
 void setTCPKeepAliveIdle(long optVal)
          Override TCP_KEEPCNT (or TCP_KEEPALIVE on some OS) socket option (where supported by OS).
 void setTCPKeepAliveInterval(long optVal)
          Override TCP_KEEPINTVL socket option (where supported by OS).
 void subscribe(byte[] topic)
          The 'ZMQ_SUBSCRIBE' option shall establish a new message filter on a 'ZMQ_SUB' socket.
 void unbind(String addr)
          Unbind from network interface.
 void unsubscribe(byte[] topic)
          The 'ZMQ_UNSUBSCRIBE' option shall remove an existing message filter on a 'ZMQ_SUB' socket.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZMQ.Socket

protected ZMQ.Socket(ZMQ.Context context,
                     int type)
Class constructor.

Parameters:
context - a 0MQ context previously created.
type - the socket type.
Method Detail

close

public void close()
This is an explicit "destructor". It can be called to ensure the corresponding 0MQ Socket has been disposed of.


getType

public int getType()
The 'ZMQ_TYPE option shall retrieve the socket type for the specified 'socket'. The socket type is specified at socket creation time and cannot be modified afterwards.

Returns:
the socket type.
Since:
2.1.0

getLinger

public long getLinger()
Returns:
the linger period.
Since:
2.1.0
See Also:
setLinger(long)

getReconnectIVL

public long getReconnectIVL()
Returns:
the reconnectIVL.
Since:
3.0.0
See Also:
setReconnectIVL(long)

getBacklog

public long getBacklog()
Returns:
the backlog.
Since:
3.0.0
See Also:
setBacklog(long)

getReconnectIVLMax

public long getReconnectIVLMax()
Returns:
the reconnectIVLMax.
Since:
3.0.0
See Also:
setReconnectIVLMax(long)

getMaxMsgSize

public long getMaxMsgSize()
Returns:
the maxMsgSize.
Since:
3.0.0
See Also:
setMaxMsgSize(long)

getSndHWM

public long getSndHWM()
Returns:
the SndHWM.
Since:
3.0.0
See Also:
setSndHWM(long)

getRcvHWM

public long getRcvHWM()
Returns:
the recvHWM period.
Since:
3.0.0
See Also:
setRcvHWM(long)

getHWM

public long getHWM()
Returns:
the High Water Mark.
See Also:
setHWM(long)

getSwap

public long getSwap()
Returns:
the number of messages to swap at most.
See Also:
setSwap(long)

getAffinity

public long getAffinity()
Returns:
the affinity.
See Also:
setAffinity(long)

getTCPKeepAliveSetting

public long getTCPKeepAliveSetting()
Returns:
the keep alive setting.
See Also:
setTCPKeepAlive(long)

getTCPKeepAliveIdle

public long getTCPKeepAliveIdle()
Returns:
the keep alive idle value.
See Also:
setTCPKeepAliveIdle(long)

getTCPKeepAliveInterval

public long getTCPKeepAliveInterval()
Returns:
the keep alive interval.
See Also:
setTCPKeepAliveInterval(long)

getTCPKeepAliveCount

public long getTCPKeepAliveCount()
Returns:
the keep alive count.
See Also:
setTCPKeepAliveCount(long)

getIdentity

public byte[] getIdentity()
Returns:
the Identitiy.
See Also:
setIdentity(byte[])

getRate

public long getRate()
Returns:
the Rate.
See Also:
setRate(long)

getRecoveryInterval

public long getRecoveryInterval()
Returns:
the RecoveryIntervall.
See Also:
setRecoveryInterval(long)

hasMulticastLoop

public boolean hasMulticastLoop()
Returns:
the Multicast Loop.
See Also:
setMulticastLoop(boolean)

setMulticastHops

public void setMulticastHops(long mcast_hops)
Sets the time-to-live field in every multicast packet sent from this socket. The default is 1 which means that the multicast packets don't leave the local network.

Parameters:
mcast_hops -

getMulticastHops

public long getMulticastHops()
Returns:
the Multicast Hops.
See Also:
setMulticastHops(long)

setReceiveTimeOut

public void setReceiveTimeOut(int timeout)
Sets the timeout for receive operation on the socket. If the value is 0, recv will return immediately, with a EAGAIN error if there is no message to receive. If the value is -1, it will block until a message is available. For all other values, it will wait for a message for that amount of time before returning with an EAGAIN error.

Parameters:
timeout - Timeout for receive operation in milliseconds. Default -1 (infinite)

getReceiveTimeOut

public int getReceiveTimeOut()
Returns:
the Receive Timeout in milliseconds
See Also:
#setReceiveTimeOut(long)

setSendTimeOut

public void setSendTimeOut(int timeout)
Sets the timeout for send operation on the socket. If the value is 0, send will return immediately, with a EAGAIN error if the message cannot be sent. If the value is -1, it will block until the message is sent. For all other values, it will try to send the message for that amount of time before returning with an EAGAIN error.

Parameters:
timeout - Timeout for send operation in milliseconds. Default -1 (infinite)

getSendTimeOut

public int getSendTimeOut()
Returns:
the Send Timeout. in milliseconds
See Also:
#setSendTimeOut(long)

getSendBufferSize

public long getSendBufferSize()
Returns:
the kernel send buffer size.
See Also:
setSendBufferSize(long)

getReceiveBufferSize

public long getReceiveBufferSize()
Returns:
the kernel receive buffer size.
See Also:
setReceiveBufferSize(long)

getIPv4Only

public boolean getIPv4Only()
Returns:
the IPv4 only socket.
See Also:
#setIPv4only(long)

hasReceiveMore

public 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. If there are no message parts to follow or if the message currently being read is not a multi-part message a value of zero shall be returned. Otherwise, a value of 1 shall be returned.

Returns:
true if there are more messages to receive.

getFD

public long getFD()
The 'ZMQ_FD' option shall retrieve file descriptor associated with the 0MQ socket. The descriptor can be used to integrate 0MQ socket into an existing event loop. It should never be used for anything else than polling -- such as reading or writing. The descriptor signals edge-triggered IN event when something has happened within the 0MQ socket. It does not necessarily mean that the messages can be read or written. Check ZMQ_EVENTS option to find out whether the 0MQ socket is readable or writeable.

Returns:
the underlying file descriptor.
Since:
2.1.0

getEvents

public long getEvents()
The 'ZMQ_EVENTS' option shall retrieve event flags for the specified socket. If a message can be read from the socket ZMQ_POLLIN flag is set. If message can be written to the socket ZMQ_POLLOUT flag is set.

Returns:
the mask of outstanding events.
Since:
2.1.0

setLinger

public void setLinger(long linger)
The 'ZMQ_LINGER' option shall retrieve the period for pending outbound messages to linger in memory after closing the socket. Value of -1 means infinite. Pending messages will be kept until they are fully transferred to the peer. Value of 0 means that all the pending messages are dropped immediately when socket is closed. Positive value means number of milliseconds to keep trying to send the pending messages before discarding them.

Parameters:
linger - the linger period.
Since:
2.1.0

setReconnectIVL

public void setReconnectIVL(long reconnectIVL)
Since:
3.0.0

setBacklog

public void setBacklog(long backlog)
Since:
3.0.0

setReconnectIVLMax

public void setReconnectIVLMax(long reconnectIVLMax)
Since:
3.0.0

setMaxMsgSize

public void setMaxMsgSize(long maxMsgSize)
Since:
3.0.0

setSndHWM

public void setSndHWM(long sndHWM)
Since:
3.0.0

setRcvHWM

public void setRcvHWM(long rcvHWM)
Since:
3.0.0

setHWM

public void setHWM(long hwm)
The 'ZMQ_HWM' option shall set the high water mark for the specified 'socket'. The high water mark is a hard limit on the maximum number of outstanding messages 0MQ shall queue in memory for any single peer that the specified 'socket' is communicating with. 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.

Parameters:
hwm - the number of messages to queue.

setSwap

public void setSwap(long swap)
Get the Swap. The 'ZMQ_SWAP' option shall set the disk offload (swap) size for the specified 'socket'. A socket which has 'ZMQ_SWAP' set to a non-zero value may exceed its high water mark; in this case outstanding messages shall be offloaded to storage on disk rather than held in memory.

Parameters:
swap - The value of 'ZMQ_SWAP' defines the maximum size of the swap space in bytes.

setAffinity

public void setAffinity(long affinity)
Get the Affinity. The 'ZMQ_AFFINITY' option shall set the I/O thread affinity for newly created connections on the specified 'socket'. 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 zmq_init[3] for details on allocating the number of I/O threads for a specific _context_.

Parameters:
affinity - the affinity.

setTCPKeepAlive

public void setTCPKeepAlive(long optVal)
Override SO_KEEPALIVE socket option (where supported by OS) to enable keep-alive packets for a socket connection. Possible values are -1, 0, 1. The default value -1 will skip all overrides and do the OS default.

Parameters:
optVal - The value of 'ZMQ_TCP_KEEPALIVE' to turn TCP keepalives on (1) or off (0).

setTCPKeepAliveCount

public void setTCPKeepAliveCount(long optVal)
Override TCP_KEEPCNT socket option (where supported by OS). The default value -1 will skip all overrides and do the OS default.

Parameters:
optVal - The value of 'ZMQ_TCP_KEEPALIVE_CNT' defines the number of keepalives before death.

setTCPKeepAliveInterval

public void setTCPKeepAliveInterval(long optVal)
Override TCP_KEEPINTVL socket option (where supported by OS). The default value -1 will skip all overrides and do the OS default.

Parameters:
optVal - The value of 'ZMQ_TCP_KEEPALIVE_INTVL' defines the interval between keepalives in ms.

setTCPKeepAliveIdle

public void setTCPKeepAliveIdle(long optVal)
Override TCP_KEEPCNT (or TCP_KEEPALIVE on some OS) socket option (where supported by OS). The default value -1 will skip all overrides and do the OS default.

Parameters:
optVal - The value of 'ZMQ_TCP_KEEPALIVE_IDLE' defines the interval between the last data packet sent over the socket and the first keepalive probe in ms.

setIdentity

public void setIdentity(byte[] identity)
The 'ZMQ_IDENTITY' option shall set the identity of the specified 'socket'. Socket identity determines if existing 0MQ infastructure (_message queues_, _forwarding devices_) shall be identified with a specific application and persist across multiple runs of the application. 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.

Parameters:
identity -

subscribe

public void subscribe(byte[] topic)
The 'ZMQ_SUBSCRIBE' option shall establish a new message filter on a 'ZMQ_SUB' socket. Newly created 'ZMQ_SUB' sockets shall filter out all incoming messages, therefore you should call this option to establish an initial message filter. 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.

Parameters:
topic -

unsubscribe

public void unsubscribe(byte[] topic)
The 'ZMQ_UNSUBSCRIBE' option shall remove an existing message filter on a 'ZMQ_SUB' socket. The filter specified must match an existing filter previously established with the 'ZMQ_SUBSCRIBE' option. If the socket has several instances of the same filter attached the 'ZMQ_UNSUBSCRIBE' option shall remove only one instance, leaving the rest in place and functional.

Parameters:
topic -

setRate

public void setRate(long rate)
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'.

Parameters:
rate -

setRecoveryInterval

public void setRecoveryInterval(long recovery_ivl)
The 'ZMQ_RECOVERY_IVL' option shall set the recovery interval for multicast transports using the specified 'socket'. The recovery interval determines the maximum time in seconds (before version 3.0.0) or milliseconds (version 3.0.0 and after) that a receiver can be absent from a multicast group before unrecoverable data loss will occur. 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}

Parameters:
recovery_ivl -

setMulticastLoop

public void setMulticastLoop(boolean mcast_loop)
The 'ZMQ_MCAST_LOOP' option shall control whether data sent via multicast transports using the specified 'socket' can also be received by the sending host via loopback. A value of zero disables the loopback functionality, while the default value of 1 enables the loopback functionality. Leaving multicast loopback enabled when it is not required can have a negative impact on performance. Where possible, disable 'ZMQ_MCAST_LOOP' in production environments.

Parameters:
mcast_loop -

setSendBufferSize

public void setSendBufferSize(long sndbuf)
The 'ZMQ_SNDBUF' option shall set the underlying kernel transmit buffer size for the 'socket' to the specified size in bytes. A value of zero means leave the OS default unchanged. For details please refer to your operating system documentation for the 'SO_SNDBUF' socket option.

Parameters:
sndbuf -

setReceiveBufferSize

public void setReceiveBufferSize(long rcvbuf)
The 'ZMQ_RCVBUF' option shall set the underlying kernel receive buffer size for the 'socket' to the specified size in bytes. A value of zero means leave the OS default unchanged. For details refer to your operating system documentation for the 'SO_RCVBUF' socket option.

Parameters:
rcvbuf -

setIPv4Only

public void setIPv4Only(boolean v4only)
The 'ZMQ_IPV4ONLY' option shall set the underlying native socket type. An IPv6 socket lets applications connect to and accept connections from both IPv4 and IPv6 hosts.

Parameters:
v4only - A value of true will use IPv4 sockets, while the value of false will use IPv6 sockets

setRouterMandatory

public void setRouterMandatory(boolean mandatory)
Sets the ROUTER socket behavior when an unroutable message is encountered.

Parameters:
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.

bind

public void bind(String addr)
Bind to network interface. Start listening for new connections.

Parameters:
addr - the endpoint to bind to.

bindToRandomPort

public int bindToRandomPort(String addr)
Bind to network interface to a random port. Start listening for new connections.

Parameters:
addr - the endpoint to bind to.

bindToRandomPort

public int bindToRandomPort(String addr,
                            int min_port)
Bind to network interface to a random port. Start listening for new connections.

Parameters:
addr - the endpoint to bind to.
min_port - The minimum port in the range of ports to try.

bindToRandomPort

public int bindToRandomPort(String addr,
                            int min_port,
                            int max_port)
Bind to network interface to a random port. Start listening for new connections.

Parameters:
addr - the endpoint to bind to.
min_port - The minimum port in the range of ports to try.
max_port - The maximum port in the range of ports to try.

bindToRandomPort

public int bindToRandomPort(String addr,
                            int min_port,
                            int max_port,
                            int max_tries)
Bind to network interface to a random port. Start listening for new connections.

Parameters:
addr - the endpoint to bind to.
min_port - The minimum port in the range of ports to try.
max_port - The maximum port in the range of ports to try.
max_tries - The number of attempt to bind.

unbind

public void unbind(String addr)
Unbind from network interface. Stop listening for connections.

Parameters:
addr - the endpoint to unbind from.

connect

public void connect(String addr)
Connect to remote application.

Parameters:
addr - the endpoint to connect to.

disconnect

public void disconnect(String addr)
Disconnect from a remote application.

Parameters:
addr - the endpoint to disconnect from.

send

public boolean send(byte[] msg,
                    int offset,
                    int flags)
Send a message.

Parameters:
msg - the message to send, as an array of bytes.
offset - the offset of the message to send.
flags - the flags to apply to the send operation.
Returns:
true if send was successful, false otherwise.

send

public boolean send(byte[] msg,
                    int offset,
                    int len,
                    int flags)
Parameters:
msg -
offset -
len -
flags -
Returns:

sendZeroCopy

public boolean sendZeroCopy(ByteBuffer buffer,
                            int len,
                            int flags)
Perform a zero copy send. The buffer must be allocated using ByteBuffer.allocateDirect

Parameters:
buffer -
len -
flags -
Returns:

send

public boolean send(byte[] msg,
                    int flags)
Send a message.

Parameters:
msg - the message to send, as an array of bytes.
flags - the flags to apply to the send operation.
Returns:
true if send was successful, false otherwise.

send

public boolean send(String msg)
Send a String.

Parameters:
msg - the message to send, as a String.
Returns:
true if send was successful, false otherwise.

sendMore

public boolean sendMore(String msg)
Send a String.

Parameters:
msg - the message to send, as a String.
Returns:
true if send was successful, false otherwise.

send

public boolean send(String msg,
                    int flags)
Send a String.

Parameters:
msg - the message to send, as a String.
flags - the flags to apply to the send operation.
Returns:
true if send was successful, false otherwise.

recv

public byte[] recv(int flags)
Receive a message.

Parameters:
flags - the flags to apply to the receive operation.
Returns:
the message received, as an array of bytes; null on error.

recv

public int recv(byte[] buffer,
                int offset,
                int len,
                int flags)
Receive a message in to a specified buffer.

Parameters:
buffer - byte[] to copy zmq message payload in to.
offset - offset in buffer to write data
len - max bytes to write to buffer. If len is smaller than the incoming message size, the message will be truncated.
flags - the flags to apply to the receive operation.
Returns:
the number of bytes read, -1 on error

recvZeroCopy

public int recvZeroCopy(ByteBuffer buffer,
                        int len,
                        int flags)
Zero copy recv

Parameters:
buffer -
len -
flags -
Returns:
bytes read, -1 on error

recv

public final byte[] recv()
Receive a message.

Returns:
the message received, as an array of bytes; null on error.

recvStr

public String recvStr()
Receive a message as a String.

Returns:
the message received, as a String; null on error.

recvStr

public String recvStr(int flags)
Receive a message as a String.

Parameters:
flags - the flags to apply to the receive operation.
Returns:
the message received, as a String; null on error.

construct

protected void construct(ZMQ.Context ctx,
                         int type)
Initialize the JNI interface


finalize

protected void finalize()
Free all resources used by JNI interface.

Overrides:
finalize in class Object

getLongSockopt

protected long getLongSockopt(int option)
Get the socket option value, as a long.

Parameters:
option - ID of the option to set.
Returns:
The socket option value (as a long).

getBytesSockopt

protected byte[] getBytesSockopt(int option)
Get the socket option value, as a byte array.

Parameters:
option - ID of the option to set.
Returns:
The socket option value (as a byte array).

setLongSockopt

protected void setLongSockopt(int option,
                              long optval)
Set the socket option value, given as a long.

Parameters:
option - ID of the option to set.
optval - value (as a long) to set the option to.

setBytesSockopt

protected void setBytesSockopt(int option,
                               byte[] optval)
Set the socket option value, given as a byte array.

Parameters:
option - ID of the option to set.
optval - value (as a byte array) to set the option to.


Copyright © 2013. All Rights Reserved.