|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.zeromq.ZMQ.Socket
public static class ZMQ.Socket
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 |
---|
protected ZMQ.Socket(ZMQ.Context context, int type)
context
- a 0MQ context previously created.type
- the socket type.Method Detail |
---|
public void close()
public int getType()
public long getLinger()
setLinger(long)
public long getReconnectIVL()
setReconnectIVL(long)
public long getBacklog()
setBacklog(long)
public long getReconnectIVLMax()
setReconnectIVLMax(long)
public long getMaxMsgSize()
setMaxMsgSize(long)
public long getSndHWM()
setSndHWM(long)
public long getRcvHWM()
setRcvHWM(long)
public long getHWM()
setHWM(long)
public long getSwap()
setSwap(long)
public long getAffinity()
setAffinity(long)
public long getTCPKeepAliveSetting()
setTCPKeepAlive(long)
public long getTCPKeepAliveIdle()
setTCPKeepAliveIdle(long)
public long getTCPKeepAliveInterval()
setTCPKeepAliveInterval(long)
public long getTCPKeepAliveCount()
setTCPKeepAliveCount(long)
public byte[] getIdentity()
setIdentity(byte[])
public long getRate()
setRate(long)
public long getRecoveryInterval()
setRecoveryInterval(long)
public boolean hasMulticastLoop()
setMulticastLoop(boolean)
public void setMulticastHops(long mcast_hops)
mcast_hops
- public long getMulticastHops()
setMulticastHops(long)
public void setReceiveTimeOut(int timeout)
timeout
- Timeout for receive operation in milliseconds. Default -1 (infinite)public int getReceiveTimeOut()
#setReceiveTimeOut(long)
public void setSendTimeOut(int timeout)
timeout
- Timeout for send operation in milliseconds. Default -1 (infinite)public int getSendTimeOut()
#setSendTimeOut(long)
public long getSendBufferSize()
setSendBufferSize(long)
public long getReceiveBufferSize()
setReceiveBufferSize(long)
public boolean getIPv4Only()
#setIPv4only(long)
public boolean hasReceiveMore()
public long getFD()
public long getEvents()
public void setLinger(long linger)
linger
- the linger period.public void setReconnectIVL(long reconnectIVL)
public void setBacklog(long backlog)
public void setReconnectIVLMax(long reconnectIVLMax)
public void setMaxMsgSize(long maxMsgSize)
public void setSndHWM(long sndHWM)
public void setRcvHWM(long rcvHWM)
public void setHWM(long hwm)
hwm
- the number of messages to queue.public void setSwap(long swap)
swap
- The value of 'ZMQ_SWAP' defines the maximum size of the swap space in bytes.public void setAffinity(long affinity)
affinity
- the affinity.public void setTCPKeepAlive(long optVal)
optVal
- The value of 'ZMQ_TCP_KEEPALIVE' to turn TCP keepalives on (1) or off (0).public void setTCPKeepAliveCount(long optVal)
optVal
- The value of 'ZMQ_TCP_KEEPALIVE_CNT' defines the number of keepalives before death.public void setTCPKeepAliveInterval(long optVal)
optVal
- The value of 'ZMQ_TCP_KEEPALIVE_INTVL' defines the interval between keepalives in ms.public void setTCPKeepAliveIdle(long optVal)
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.public void setIdentity(byte[] identity)
identity
- public void subscribe(byte[] topic)
topic
- public void unsubscribe(byte[] topic)
topic
- public void setRate(long rate)
rate
- public void setRecoveryInterval(long recovery_ivl)
recovery_ivl
- public void setMulticastLoop(boolean mcast_loop)
mcast_loop
- public void setSendBufferSize(long sndbuf)
sndbuf
- public void setReceiveBufferSize(long rcvbuf)
rcvbuf
- public void setIPv4Only(boolean v4only)
v4only
- A value of true will use IPv4 sockets, while the value of false will use IPv6 socketspublic void 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 void 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_port)
addr
- the endpoint to bind to.min_port
- The minimum port in the range of ports to try.public int bindToRandomPort(String addr, int min_port, int max_port)
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.public int bindToRandomPort(String addr, int min_port, int max_port, int max_tries)
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.public void unbind(String addr)
addr
- the endpoint to unbind from.public void connect(String addr)
addr
- the endpoint to connect to.public void disconnect(String addr)
addr
- the endpoint to disconnect from.public boolean send(byte[] msg, int offset, int flags)
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.
public boolean send(byte[] msg, int offset, int len, int flags)
msg
- offset
- len
- flags
-
public boolean sendZeroCopy(ByteBuffer buffer, int len, int flags)
buffer
- len
- flags
-
public boolean send(byte[] msg, int flags)
msg
- the message to send, as an array of bytes.flags
- the flags to apply to the send operation.
public boolean send(String msg)
msg
- the message to send, as a String.
public boolean sendMore(String msg)
msg
- the message to send, as a String.
public boolean send(String msg, int flags)
msg
- the message to send, as a String.flags
- the flags to apply to the send operation.
public byte[] recv(int flags)
flags
- the flags to apply to the receive operation.
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
- the flags to apply to the receive operation.
public int recvZeroCopy(ByteBuffer buffer, int len, int flags)
buffer
- len
- flags
-
public final byte[] recv()
public String recvStr()
public String recvStr(int flags)
flags
- the flags to apply to the receive operation.
protected void construct(ZMQ.Context ctx, int type)
protected void finalize()
finalize
in class Object
protected long getLongSockopt(int option)
option
- ID of the option to set.
protected byte[] getBytesSockopt(int option)
option
- ID of the option to set.
protected void setLongSockopt(int option, long optval)
option
- ID of the option to set.optval
- value (as a long) to set the option to.protected void setBytesSockopt(int option, byte[] optval)
option
- ID of the option to set.optval
- value (as a byte array) to set the option to.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |