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)
getGssapiPrincipal
char[] getGssapiPrincipal(char[] dest)
getGssapiServicePrincipal
char[] getGssapiServicePrincipal(char[] dest)
getIdentity
ubyte[] getIdentity(ubyte[] dest)
getPlainPassword
char[] getPlainPassword(char[] dest)
getPlainUsername
char[] getPlainUsername(char[] dest)
getZapDomain
char[] getZapDomain(char[] dest)

$(ANCHOR Socket.misc_options) Miscellaneous 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(char[] filterPrefix)

Establishes a message filter.

subscribe
void subscribe(ubyte[] 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(char[] filterPrefix)

Removes a message filter.

unsubscribe
void unsubscribe(ubyte[] filterPrefix)

Removes a message filter.

Properties

backlog
int backlog [@property getter]
int backlog [@property setter]
conflate
bool conflate [@property setter]
connectionRID
ubyte[] connectionRID [@property setter]
curvePublicKey
const(ubyte)[] curvePublicKey [@property setter]
ubyte[] curvePublicKey [@property getter]
curvePublicKeyZ85
const(char)[] curvePublicKeyZ85 [@property setter]
char[] curvePublicKeyZ85 [@property getter]
curveSecretKey
const(ubyte)[] curveSecretKey [@property setter]
ubyte[] curveSecretKey [@property getter]
curveSecretKeyZ85
const(char)[] curveSecretKeyZ85 [@property setter]
char[] curveSecretKeyZ85 [@property getter]
curveServer
bool curveServer [@property setter]
bool curveServer [@property getter]
curveServerKey
const(ubyte)[] curveServerKey [@property setter]
ubyte[] curveServerKey [@property getter]
curveServerKeyZ85
const(char)[] curveServerKeyZ85 [@property setter]
char[] curveServerKeyZ85 [@property getter]

$(ANCHOR Socket.misc_options) Miscellaneous socket options.

delayAttachOnConnect
deprecated bool delayAttachOnConnect [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
delayAttachOnConnect
deprecated bool delayAttachOnConnect [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
events
PollFlags events [@property getter]
fd
FD fd [@property getter]
gssapiPlaintext
bool gssapiPlaintext [@property setter]
bool gssapiPlaintext [@property getter]
gssapiPrincipal
char[] gssapiPrincipal [@property setter]
char[] gssapiPrincipal [@property getter]
gssapiServer
bool gssapiServer [@property setter]
bool gssapiServer [@property getter]
gssapiServicePrincipal
char[] gssapiServicePrincipal [@property setter]
char[] gssapiServicePrincipal [@property getter]

$(ANCHOR Socket.misc_options) Miscellaneous socket options.

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

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

handshakeInterval
Duration handshakeInterval [@property setter]
Duration handshakeInterval [@property getter]
identity
ubyte[] identity [@property getter]
ubyte[] identity [@property setter]
char[] identity [@property setter]
immediate
bool immediate [@property getter]
bool immediate [@property setter]

$(ANCHOR Socket.misc_options) Miscellaneous 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]
Undocumented in source. Be warned that the author may not have intended to support it.
ipv4Only
deprecated bool ipv4Only [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
ipv6
bool ipv6 [@property setter]
bool ipv6 [@property getter]
lastEndpoint
char[] lastEndpoint [@property getter]
linger
Duration linger [@property setter]
Duration linger [@property getter]
maxMsgSize
long maxMsgSize [@property setter]
long maxMsgSize [@property getter]
maxReconnectionInterval
Duration maxReconnectionInterval [@property setter]
Duration maxReconnectionInterval [@property getter]
mechanism
Security mechanism [@property getter]

$(ANCHOR Socket.misc_options) Miscellaneous socket options.

more
bool more [@property getter]

Whether there are more message frames to follow.

multicastHops
int multicastHops [@property setter]
int multicastHops [@property getter]
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 setter]
int rate [@property getter]
receiveBufferSize
int receiveBufferSize [@property setter]
int receiveBufferSize [@property getter]
receiveHWM
int receiveHWM [@property setter]
int receiveHWM [@property getter]
receiveTimeout
Duration receiveTimeout [@property setter]
Duration receiveTimeout [@property getter]
reconnectionInterval
Duration reconnectionInterval [@property setter]
Duration reconnectionInterval [@property getter]
recoveryInterval
Duration recoveryInterval [@property setter]
Duration recoveryInterval [@property getter]
reqCorrelate
bool reqCorrelate [@property setter]
reqRelaxed
bool reqRelaxed [@property setter]
routerHandover
bool routerHandover [@property setter]
routerMandatory
bool routerMandatory [@property setter]
sendBufferSize
int sendBufferSize [@property setter]
int sendBufferSize [@property getter]
sendHWM
int sendHWM [@property setter]
int sendHWM [@property getter]
sendTimeout
Duration sendTimeout [@property setter]
Duration sendTimeout [@property getter]
tcpKeepalive
int tcpKeepalive [@property setter]
int tcpKeepalive [@property getter]
tcpKeepaliveCnt
int tcpKeepaliveCnt [@property setter]
int tcpKeepaliveCnt [@property getter]
tcpKeepaliveIdle
int tcpKeepaliveIdle [@property setter]
int tcpKeepaliveIdle [@property getter]
tcpKeepaliveIntvl
int tcpKeepaliveIntvl [@property setter]
int tcpKeepaliveIntvl [@property getter]
threadAffinity
ulong threadAffinity [@property setter]

$(ANCHOR Socket.misc_options) Miscellaneous socket options.

threadAffinity
ulong threadAffinity [@property getter]
type
SocketType type [@property getter]
typeOfService
int typeOfService [@property getter]
int typeOfService [@property setter]
xpubVerbose
bool xpubVerbose [@property setter]
zapDomain
char[] zapDomain [@property getter]
char[] zapDomain [@property setter]

$(ANCHOR Socket.misc_options) Miscellaneous 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