public class ZSocket extends Object implements AutoCloseable
ZeroMQ sockets being asynchronous means that the timings of the physical connection setup and tear down, reconnect and effective delivery are transparent to the user and organized by ZeroMQ itself. Further, messages may be queued in the event that a peer is unavailable to receive them.
Constructor and Description |
---|
ZSocket(int socketType)
Create a ZeroMQ socket
|
Modifier and Type | Method and Description |
---|---|
boolean |
bind(String endpoint)
Creates an endpoint for accepting connections and binds to it.
|
void |
close() |
boolean |
connect(String endpoint)
Connects the socket to an endpoint and then accepts incoming connections on that endpoint.
|
boolean |
disconnect(String endpoint)
Disconnecting a socket from an endpoint.
|
int |
getType()
Retrieve the socket type for the current 'socket'.
|
boolean |
hasReceiveMore()
Returns a boolean value indicating if the multipart message currently being read from the
Socket and has more message parts to follow. |
byte[] |
receive() |
byte[] |
receive(int flags) |
String |
receiveStringUtf8() |
String |
receiveStringUtf8(int flags) |
int |
send(byte[] b) |
int |
send(byte[] b,
int flags) |
boolean |
sendFrame(ZFrame frame,
int flags)
Send a frame
|
boolean |
sendMessage(ZMsg message) |
int |
sendStringUtf8(String str) |
int |
sendStringUtf8(String str,
int flags) |
void |
subscribe(byte[] topic) |
void |
subscribe(String topic) |
boolean |
unbind(String endpoint)
Stop accepting connections on a socket.
|
void |
unsubscribe(byte[] topic) |
void |
unsubscribe(String topic) |
public static final Charset UTF8
public ZSocket(int socketType)
socketType
- ZeroMQ socket typepublic int getType()
public boolean bind(String endpoint)
The endpoint argument is a string consisting of two parts as follows: transport ://address. The transport part specifies the underlying transport protocol to use. The meaning of the address part is specific to the underlying transport protocol selected.
endpoint
- the endpoint to bind topublic boolean unbind(String endpoint)
Shall unbind from the endpoint specified by the endpoint argument.
endpoint
- the endpoint to unbind frompublic boolean connect(String endpoint)
The endpoint is a string consisting of a transport :// followed by an address. The transport specifies the underlying protocol to use. The address specifies the transport-specific address to connect to.
endpoint
- the endpoint to connect topublic boolean disconnect(String endpoint)
endpoint
- the endpoint to disconnect frompublic final boolean hasReceiveMore()
Socket
and has more message parts to follow. If there are no message parts to follow or
if the message currently being read is not a multipart message a value of false shall be
returned. Otherwise, a value of true shall be returned.public void subscribe(byte[] topic)
public void subscribe(String topic)
public void unsubscribe(byte[] topic)
public void unsubscribe(String topic)
public int send(byte[] b)
public int send(byte[] b, int flags)
public boolean sendFrame(ZFrame frame, int flags)
frame
- flags
- public boolean sendMessage(ZMsg message)
public int sendStringUtf8(String str)
public int sendStringUtf8(String str, int flags)
public byte[] receive()
public byte[] receive(int flags)
public String receiveStringUtf8()
public String receiveStringUtf8(int flags)
public void close()
close
in interface AutoCloseable
Copyright © 2017. All Rights Reserved.