Socket

An object that encapsulates a $(ZMQ) socket.

A default-initialized Socket is not a valid $(ZMQ) socket; it must always be explicitly initialized with a constructor (see _Socket.this):

Socket s;                     // Not a valid socket yet
s = Socket(SocketType.push);  // ...but now it is.

Socket objects can be passed around by value, and two copies will refer to the same socket. The underlying socket is managed using reference counting, so that when the last copy of a Socket goes out of scope, the socket is automatically closed.

struct Socket {}

Constructors

this
this(SocketType type)
this(Context context, SocketType type)

Creates a new $(ZMQ) socket.

Members

Aliases

FD
alias FD = SOCKET
Undocumented in source.
FD
alias FD = int
Undocumented in source.

Functions

bind
void bind(char[] endpoint)

Starts accepting incoming connections on endpoint.

close
void close()

Closes the $(ZMQ) socket.

connect
void connect(char[] endpoint)

Creates an outgoing connection to endpoint.

disconnect
void disconnect(char[] endpoint)

Disconnects the socket from endpoint.

receive
size_t receive(ubyte[] data)

Receives a message part.

receive
size_t receive(Message msg)

Receives a message part.

send
void send(ubyte[] data, bool more)
void send(char[] data, bool more)

Sends a message part.

send
void send(Message msg, bool more)

Sends a message part.

subscribe
void subscribe(ubyte[] filterPrefix)
void subscribe(char[] filterPrefix)

Establishes a message filter.

tryReceive
Tuple!(size_t, bool) tryReceive(ubyte[] data)

Receives a message part.

tryReceive
Tuple!(size_t, bool) tryReceive(Message msg)

Receives a message part.

trySend
bool trySend(ubyte[] data, bool more)
bool trySend(char[] data, bool more)

Sends a message part.

trySend
bool trySend(Message msg, bool more)

Sends a message part.

unbind
void unbind(char[] endpoint)

Stops accepting incoming connections on endpoint.

unsubscribe
void unsubscribe(ubyte[] filterPrefix)
void unsubscribe(char[] filterPrefix)

Removes a message filter.

Properties

backlog
int backlog [@property getter]
int backlog [@property setter]
delayAttachOnConnect
bool delayAttachOnConnect [@property getter]
bool delayAttachOnConnect [@property setter]
events
int events [@property getter]
fd
FD fd [@property getter]

Misc. socket properties.

handle
inout(void)* handle [@property getter]

The void* pointer used by the underlying C API to refer to the socket.

identity
ubyte[] identity [@property getter]
ubyte[] identity [@property setter]
char[] identity [@property setter]

Misc. socket properties.

initialized
bool initialized [@property getter]

Whether this Socket object has been initialized, i.e. whether it refers to a valid $(ZMQ) socket.

ipv4Only
bool ipv4Only [@property getter]
bool ipv4Only [@property setter]
lastEndpoint
char[] lastEndpoint [@property getter]
linger
int linger [@property getter]
int linger [@property setter]
maxMsgSize
long maxMsgSize [@property getter]
long maxMsgSize [@property setter]
maxReconnectionInterval
int maxReconnectionInterval [@property getter]
int maxReconnectionInterval [@property setter]

Misc. socket properties.

more
bool more [@property getter]

Whether there are more message data parts to follow.

multicastHops
int multicastHops [@property getter]
int multicastHops [@property setter]
rate
int rate [@property getter]
int rate [@property setter]
receiveBufferSize
int receiveBufferSize [@property getter]
int receiveBufferSize [@property setter]
receiveHWM
int receiveHWM [@property getter]
int receiveHWM [@property setter]
receiveTimeout
int receiveTimeout [@property getter]
int receiveTimeout [@property setter]
reconnectionInterval
int reconnectionInterval [@property getter]
int reconnectionInterval [@property setter]
recoveryInterval
int recoveryInterval [@property getter]
int recoveryInterval [@property setter]
sendBufferSize
int sendBufferSize [@property getter]
int sendBufferSize [@property setter]

Misc. socket properties.

sendHWM
int sendHWM [@property getter]
int sendHWM [@property setter]
sendTimeout
int sendTimeout [@property getter]
int sendTimeout [@property setter]
threadAffinity
ulong threadAffinity [@property getter]
ulong threadAffinity [@property setter]

Misc. socket properties.

type
SocketType type [@property getter]

The socket type.

Meta