ADDED build-assist/ck5-eggs.list Index: build-assist/ck5-eggs.list ================================================================== --- /dev/null +++ build-assist/ck5-eggs.list @@ -0,0 +1,43 @@ +address-info +ansi-escape-sequences +apropos +base64 +crypt +csv-abnf +directory-utils +filepath +fmt +format +http-client +itemsmod +json +linenoise +md5 +message-digest +nanomsg +postgresql +queues +regex +regex-case +rfc3339 +s11n +sha1 +slice +sparse-vectors +spiffy +spiffy-directory-listing +spiffy-request-vars +sql-de-lite +sqlite3 +sql-null +srfi-1 +srfi-13 +srfi-19 +sxml-modifications +sxml-serializer +sxml-transforms +system-information +test +typed-records +uri-common +z3 ADDED build-assist/debian-packages-needed Index: build-assist/debian-packages-needed ================================================================== --- /dev/null +++ build-assist/debian-packages-needed @@ -0,0 +1,5 @@ +build-essential +libnanomsg-dev +libpq-dev +libsqlite3-dev +sqlite3 ADDED nng-trial/Makefile Index: nng-trial/Makefile ================================================================== --- /dev/null +++ nng-trial/Makefile @@ -0,0 +1,5 @@ +nng-test : nng-test.scm + csc nng-test.scm + +test : nng-test + ./nng-test do-test Index: nng-trial/nng-test.scm ================================================================== --- nng-trial/nng-test.scm +++ nng-trial/nng-test.scm @@ -1,37 +1,27 @@ (import (chicken io) (chicken string) + (chicken process-context) + (chicken process-context posix) miscmacros nng srfi-18 - test) + test + matchable + typed-records) +(define help "Usage: nng-test COMMAND + where COMMAND is one of: + dotest : run the basic req/rep test +") (define address-tcp-1 "tcp://localhost:5555") (define address-tcp-2 "tcp://localhost:6666") -(define address-tls+tcp-1 "tls+tcp://localhost:5555") - (define address-inproc-1 "inproc://local1") (define address-inproc-2 "inproc://local2") -(tls-register!) - -(define cert - (if (tls-enabled?) - (with-input-from-file "cert.pem" - (lambda () - (read-string))) - #f)) - -(define key - (if (tls-enabled?) - (with-input-from-file "key.pem" - (lambda () - (read-string))) - #f)) - ;;; ;;; Req-Rep ;;; (define (make-listening-reply-socket address) (let ((socket (make-rep-socket))) @@ -46,26 +36,62 @@ socket)) (define (req-rep-test address) (let ((rep (make-listening-reply-socket address)) (req (make-dialed-request-socket address))) - (nng-send req "message") + (nng-send req "message 1") (nng-recv rep) (nng-send rep "message") (begin0 (nng-recv req) (nng-close! rep)))) - -(test-group "nng" - - (test "tcp req-rep" - "message" - (req-rep-test address-tcp-1)) - - (test "inproc req-rep" - "message" - (req-rep-test address-inproc-1)) - - ) - -(test-exit) +(define (do-test) + (test-group "nng" + (test "tcp req-rep" + "message" + (req-rep-test address-tcp-1)) + (test "inproc req-rep" + "message" + (req-rep-test address-inproc-1))) + (test-exit)) + +(defstruct srv + myaddr + remaddr + req + rep + name) + +(define (server-setup myname myaddr remoteaddr) + (let* ((srvdat (make-srv))) + (srv-myaddr-set! srvdat myaddr) + (srv-remaddr-set! srvdat remoteaddr) + (srv-rep-set! srvdat (make-listening-reply-socket myaddr)) + (srv-req-set! srvdat (make-dialed-request-socket myaddr)) + (srv-name-set! srvdat myname) + srvdat)) + +(define (send-n-messages n srvdat) + (let* ((name (srv-name srvdat))) + (let loop ((i 0)) + (if (< i n) + (begin + (print "send: "(nng-send (srv-req srvdat) (conc name "-" i))) + (print "receive: "(nng-recv (srv-rep srvdat))) + (loop (+ i 1))))))) + +(define (close-srv srvdat) + (nng-close! (srv-rep srvdat))) + +(match + (command-line-arguments) + (("do-test")(do-test)) + (("send-n" n myaddr toaddr) + (let ((n-num (string->number n)) + (sdat (server-setup "just testing" myaddr toaddr))) + (send-n-messages n-num sdat) + (close-srv sdat))) + ((cmd)(print "ERROR: command "cmd", not recognised.\n\n"help)) + (else + (print help))) +