NNGSocket

{NNGSocket} The main socket wrapper Socket may be created of one of the above described types Most types has dialer-listener pairs: PUSH/PULL, REQ/REP, PUB/SUB... Methods: - constructor -- type -- raw flag (see NNG doc) - close: close socket, wait for status changes

@setup listener - listen: bind listener to URL (addres, port, proto etc) (listener_create + listener_start) -- URL like "tcp://...", "ipc://...", "udp://...", "ws://...." -- nonblock flag (see NNG doc) - listener_create: create but not start ( for aio and tls ) -- URL - listener_set_tls: attach the prepared NNGTLS - listener_start: do listen

@setup dialer - dial: try connect to remote lustener (dialer_create + dialer_start) -- URL -- nonblock flag - dialer_create -- URL - dialer_set_tls: attach the prepared NNGTLS - dialer_start: do dial

@setup sbscription ( for SUB only ) - subscribe -- tag - unsubscribe -- tag - clear_subscriptions: unsubscribe all - subscriptions: return list of subscriptions

@send&receive - sendmsg -- NNGMessage message - send(template): send any type or array - sendaio: async send with poller -- NNGAio with previously added NNGMessage - receivebuf -- ubute[] buffer -- size - receivemsg -- NNGMessage - reveive (template): receive any type or array - receiveaio: async receive with wait poller

Properties:

- state: curent state like NEW, ERROR, CONNECTED... - errno: last error - type: socket type - name: socket name - raw: raw flag

NNG properties:

There are dozens properties of several scopes - socket, listener, dialer, protocol, etc. See NNG docs. Currently implemented; - proto - protoname - peer - peername - recvbuf - sendbuf - recvfd - recvtimeout - sendtimeout - locaddr - remaddr - url - maxttl - recvmaxsz - reconnmint - reconnmaxt

Constructors

this
this(nng_socket_type itype, bool iraw)

Creator. Param: socket type

Members

Functions

clearsubscribe
int clearsubscribe()

Unsubscrbe all subscribed

close
int close()

Terminate, wait and close

dial
int dial(const(string) url, bool nonblock)

Create and start dialer

dialer_create
int dialer_create(const(string) url)

Create dialer

dialer_set_tls
int dialer_set_tls(NNGTLS* tls)

Assign NNGTLS to dialer

dialer_start
int dialer_start(bool nonblock)

Start dialer

listen
int listen(const(string) url, bool nonblock)

Create and start listener

listener_create
int listener_create(const(string) url)

Create listener Param: URL

listener_set_tls
int listener_set_tls(NNGTLS* tls)

Add NNGTLS to listener

listener_start
int listener_start(bool nonblock)

Start listener

receive
T receive(bool nonblock)

Receives a data type (castable to byte array) as postallocated buffer

receiveaio
int receiveaio(NNGAio aio)

Receive NNGMessage with AIO Returns zero or error code

receivebuf
size_t receivebuf(ubyte[] data, size_t sz, bool nonblock)

Receives a data buffer of the max size data.length

receivemsg
int receivemsg(NNGMessage* msg, bool nonblock)

Receives NNGMessage

send
int send(const(T) data, bool nonblock)

Send any array type Returns zero or error code

sendaio
int sendaio(NNGAio aio)

Send NNGMessage with AIO Returns zero or error code

sendmsg
int sendmsg(NNGMessage msg, bool nonblock)

Send NNGMessage Returns zero or error code

subscribe
int subscribe(string tag)

Subscribe SUB socket to tag

subscriptions
string[] subscriptions()

Returns list of subscriptions

unsubscribe
int unsubscribe(string tag)

Unsubscribe SUB socket from tag

Properties

maxttl
uint maxttl [@property setter]

MAXTTL a value between 0 and 255, inclusive. Where 0 is infinite