chickadee » nng

nng

Barebones libnng bindings for CHICKEN Scheme. rep, req, pull, push, sub, pub, pair, surveyor, respondent and bus sockets are supported. Feedback and patches are very welcome!

Requirements

Usage

Socket creation

make-rep-socketprocedure
make-req-socketprocedure
make-pull-socketprocedure
make-push-socketprocedure
make-pub-socketprocedure
make-sub-socketprocedure
make-pair-socketprocedure
make-surveyor-socketprocedure
make-respondent-socketprocedure
make-bus-socketprocedure

Spawn a specific socket type. All sockets are closed automatically when their finalizers run.

Socket/listener/dialer options

socket-get socket optionprocedure
socket-set! socket option valueprocedure
listener-get listener optionprocedure
listener-set! listener option valueprocedure
dialer-get dialer optionprocedure
dialer-set! dialer option valueprocedure

option is object-specific. Currently supported options are:

  • nng/recvtimeo
  • nng/sendtimeo
  • nng/sub-subscribe
  • nng/recvmaxsz

Listening/Dialing

make-listener socket addressprocedure

Make listener from socket to bind to address.

make-dialer socket addressprocedure

Make a dialer from socket to connect to address.

listener-start! listenerprocedure

Bind listener.

dialer-start! dialerprocedure

Connect dialer.

nng-listen socket address #!optional listenerprocedure

Bind a socket to an address.

nng-dial socket address #!optional dialerprocedure

Connect a socket to an address.

Send/Recv

nng-send socket msgprocedure

Send string msg through a socket.

nng-recv socket #!optional non-blocking?procedure

Receive msg through a socket. If non-blocking? is passed and is not false, nng-recv returns #f when it would otherwise block. Additionally, if a timeout has been set with nng-socket-set-recv-timeout!, #f is returned when said timeout is reached.

Closing

nng-close! socketprocedure

Close socket explicitly.

listener-close! listenerprocedure

Close listener explicitly. Should not be necessary since listeners get close whenever their associated sockets get closed.

dialer-close! dialerprocedure

Same as above; usually unnecessary.

TLS Transport

tls-register!procedure

Register TLS transport. Usually not necessary, but depends on how your libnng was built.

tls-enabled?procedure

Check if TLS is enabled in your system.

set-listener-tls-own-certificate! listener cert key enforce-client-auth? #!optional passprocedure

Configure listener with a certificate, secret key and a (possible) passphrase. If enfonce-client-auth? is #t, it will require clients to authenticate themselves.

set-dialer-tls-certificate! dialer chain #!optional server-name key passprocedure

Configure dialer with a certificate. server-name defaults to localhost. If the certificate is its own, also provide a private key, and passphrase if applicable.

Repository

https://gitlab.com/ariSun/chicken-nng

Bugs/Caveats/TODOs

License

Copyright 2021 Ariela Wenner arisunz at disroot dot org

Licensed under MIT.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Contents »