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 $(FREF _Socket.this)):

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

This struct is noncopyable, which means that a socket is always uniquely managed by a single Socket object. Functions that will inspect or use the socket, but not take ownership of it, should take a ref Socket parameter. Use $(STDREF algorithm,move) to move a Socket to a different location (e.g. into a sink function that takes it by value, or into a new variable).

The socket is automatically closed when the Socket object goes out of scope.

More...
@safe
struct Socket {}

Constructors

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

Creates a new $(ZMQ) socket.

Destructor

~this
~this()
Undocumented in source.

Postblit

this(this)
this(this)
Undocumented in source.

Members

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.

getCurvePublicKey
ubyte[] getCurvePublicKey(ubyte[] dest)
getCurvePublicKeyZ85
char[] getCurvePublicKeyZ85(char[] dest)
getCurveSecretKey
ubyte[] getCurveSecretKey(ubyte[] dest)
getCurveSecretKeyZ85
char[] getCurveSecretKeyZ85(char[] dest)
getCurveServerKey
ubyte[] getCurveServerKey(ubyte[] dest)
getCurveServerKeyZ85
char[] getCurveServerKeyZ85(char[] dest)
getIdentity
ubyte[] getIdentity(ubyte[] dest)
getPlainPassword
char[] getPlainPassword(char[] dest)
getPlainUsername
char[] getPlainUsername(char[] dest)
getZapDomain
char[] getZapDomain(char[] dest)

Misc. socket options.

monitor
void monitor(char[] endpoint, EventType events)

Spawns a PAIR socket that publishes socket state changes (events) over the INPROC transport to the given endpoint.

receive
size_t receive(ubyte[] data)

Receives a message frame.

receive
size_t receive(Frame msg)

Receives a message frame.

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

Sends a message frame.

send
void send(Frame msg, bool more)

Sends a message frame.

sendConst
void sendConst(ubyte[] data, bool more)
void sendConst(string data, bool more)

Sends a constant-memory message frame.

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

Establishes a message filter.

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

Receives a message frame.

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

Receives a message frame.

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

Sends a message frame.

trySend
bool trySend(Frame msg, bool more)

Sends a message frame.

trySendConst
bool trySendConst(ubyte[] data, bool more)
bool trySendConst(string data, bool more)

Sends a constant-memory message frame.

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]
conflate
bool conflate [@property setter]
curvePublicKey
ubyte[] curvePublicKey [@property getter]
const(ubyte)[] curvePublicKey [@property setter]
curvePublicKeyZ85
char[] curvePublicKeyZ85 [@property getter]
const(char)[] curvePublicKeyZ85 [@property setter]
curveSecretKey
ubyte[] curveSecretKey [@property getter]
const(ubyte)[] curveSecretKey [@property setter]
curveSecretKeyZ85
char[] curveSecretKeyZ85 [@property getter]
const(char)[] curveSecretKeyZ85 [@property setter]
curveServer
bool curveServer [@property getter]
bool curveServer [@property setter]
curveServerKey
ubyte[] curveServerKey [@property getter]
const(ubyte)[] curveServerKey [@property setter]
curveServerKeyZ85
char[] curveServerKeyZ85 [@property getter]
const(char)[] curveServerKeyZ85 [@property setter]
delayAttachOnConnect
deprecated bool delayAttachOnConnect [@property getter]
deprecated bool delayAttachOnConnect [@property setter]
events
PollFlags events [@property getter]
fd
FD fd [@property getter]

Misc. socket options.

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]
immediate
bool immediate [@property getter]
bool immediate [@property setter]

Misc. socket options.

initialized
bool initialized [@property getter]

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

ipv4Only
deprecated bool ipv4Only [@property getter]
deprecated bool ipv4Only [@property setter]
ipv6
bool ipv6 [@property getter]
bool ipv6 [@property setter]
lastEndpoint
char[] lastEndpoint [@property getter]
linger
Duration linger [@property getter]
Duration linger [@property setter]
maxMsgSize
long maxMsgSize [@property getter]
long maxMsgSize [@property setter]
maxReconnectionInterval
Duration maxReconnectionInterval [@property getter]
Duration maxReconnectionInterval [@property setter]
mechanism
Security mechanism [@property getter]

Misc. socket options.

more
bool more [@property getter]

Whether there are more message frames to follow.

multicastHops
int multicastHops [@property getter]
int multicastHops [@property setter]
plainPassword
const(char)[] plainPassword [@property setter]
plainServer
bool plainServer [@property getter]
bool plainServer [@property setter]
plainUsername
const(char)[] plainUsername [@property setter]
probeRouter
bool probeRouter [@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
Duration receiveTimeout [@property getter]
Duration receiveTimeout [@property setter]
reconnectionInterval
Duration reconnectionInterval [@property getter]
Duration reconnectionInterval [@property setter]
recoveryInterval
Duration recoveryInterval [@property getter]
Duration recoveryInterval [@property setter]
reqCorrelate
bool reqCorrelate [@property setter]
reqRelaxed
bool reqRelaxed [@property setter]
routerMandatory
bool routerMandatory [@property setter]
sendBufferSize
int sendBufferSize [@property getter]
int sendBufferSize [@property setter]

Misc. socket options.

sendHWM
int sendHWM [@property getter]
int sendHWM [@property setter]
sendTimeout
Duration sendTimeout [@property getter]
Duration sendTimeout [@property setter]
tcpKeepalive
int tcpKeepalive [@property getter]
int tcpKeepalive [@property setter]
tcpKeepaliveCnt
int tcpKeepaliveCnt [@property getter]
int tcpKeepaliveCnt [@property setter]
tcpKeepaliveIdle
int tcpKeepaliveIdle [@property getter]
int tcpKeepaliveIdle [@property setter]
tcpKeepaliveIntvl
int tcpKeepaliveIntvl [@property getter]
int tcpKeepaliveIntvl [@property setter]
threadAffinity
ulong threadAffinity [@property getter]
ulong threadAffinity [@property setter]

Misc. socket options.

type
SocketType type [@property getter]

The socket type.

xpubVerbose
bool xpubVerbose [@property setter]
zapDomain
char[] zapDomain [@property getter]
char[] zapDomain [@property setter]

Misc. socket options.

Detailed Description

Linger period

Note that Socket by default sets the socket's linger period to zero. This deviates from the $(ZMQ) default (which is an infinite linger period).

Meta