NanoSocket

NanoSocket - high level wrapper for a nanomsg socket

Constructors

this
this(Protocol protocol, int domain)

constructor

this
this(Protocol protocol, BindTo bindTo, int domain)

constructor

this
this(Protocol protocol, ConnectTo connectTo, int domain)

constructor

Destructor

~this
~this()

destructor

Postblit

this(this)
this(this)

this(this) disabled to avoid sockets being destroyed

Members

Enums

Option
enum Option

nanomsg socket options

Protocol
enum Protocol

nanomsg protocol

Functions

bind
void bind(string uri, string file, size_t line)

bind

close
void close()

close socket

connect
void connect(string uri, string file, size_t line)

connect

getOption
T getOption(Option option)

get socket option value

initialize
void initialize(Protocol protocol, int domain)

Same as the revelant constructor, can be used on exisiting objects

initialize
void initialize(Protocol protocol, BindTo bindTo, int domain)

Same as the revelant constructor, can be used on exisiting objects

initialize
void initialize(Protocol protocol, ConnectTo connectTo, int domain)

Same as the revelant constructor, can be used on exisiting objects

nanoSock
int nanoSock()

get the underlying nanomsg socket file descriptor. Bear in mind that NanoSocket contains state about the socket options, so changing these from the raw fd will result in unpredictable behaviour

protocol
Protocol protocol()

get protocol

receive
NanoBuffer receive(Flag!"blocking" blocking, string file, size_t line)

Receive bytes on this socket. Memory is allocated by nanomsg and deleted in the NanoBuffer destructor.

receive
void[] receive(void[] buffer, Flag!"blocking" blocking, string file, size_t line)

A version of receive that takes a user supplied buffer to fill

send
NanoBuffer send(T[] data, Flag!"blocking" blocking, string file, size_t line)

Sends the bytes as expected. If the protocol is Request, then returns the response, otherwise returns a view of the input data.

setOption
inout(NanoSocket) setOption(Option option, T val)

set socket option to a value

toString
string toString()

toString

trySend
auto trySend(T[] data, Duration totalDuration, Flag!"blocking" recvBlocking)

Tries to send bytes to the other side. duration is how long to try for recvBlocking controls whether or not to block on reception of a response. This only matters when the protocol is request/response Returns the response if in request mode, otherwise an empty byte slice.

trySend
NanoBuffer trySend(T[] data, TotalDuration totalDuration, RetryDuration retryDuration, Flag!"blocking" recvBlocking)

Tries to send bytes to the other side. duration is how long to try for recvBlocking controls whether or not to block on reception of a response. This only matters when the protocol is request/response Returns the response if in request mode, otherwise an empty byte slice.

uri
string uri()

get URI

Manifest constants

INVALID_FD
enum INVALID_FD;

invalid FD