Index: rmtmod.scm ================================================================== --- rmtmod.scm +++ rmtmod.scm @@ -149,11 +149,13 @@ (hostport #f) (ipaddr #f) (port #f) (srvpkt #f) (lastmsg 0) - (expires 0)) + (expires 0) + (inport #f) + (outport #f)) ;;====================================================================== ;; S U P P O R T F U N C T I O N S ;;====================================================================== @@ -268,28 +270,33 @@ (conns *rmt:remote*) (dbname (db:run-id->dbname rid))) (rmt:general-open-connection conns apath dbname) (rmt:send-receive-real conns apath dbname cmd params))) -(define (rmt:send-receive-real host port data) - (let-values ((i o) (tcp-connect host port)) - (write-line data o) - (print (read-line i)))) +(define (rmt:send-receive-setup conn) + (if (not (rmt:conn-inport conn)) + (let-values ((i o) (tcp-connect (rmt:conn-ipaddr conn) + (rmt:conn-port port))) + (rmt:conn-inport-set! conn i) + (rmt:conn-outport-set! conn o)))) ;; db is at apath/.db/dbname, rid is an intermediary solution and will be removed ;; sometime in the future ;; -#;(define (rmt:send-receive-real remote apath dbname cmd params) +(define (rmt:send-receive-real remote apath dbname cmd params) (let* ((conn (rmt:get-conn remote apath dbname))) (assert conn "FATAL: rmt:send-receive-real called without the needed channels opened") - (let* ((payload (sexpr->string params)) - (res (with-input-from-request - (rmt:conn->uri conn "api") - `((params . ,payload) - (cmd . ,cmd) - (key . "nokey")) - read-string))) + (rmt:send-receive-setup conn) + (let* ((key #f) + (payload (sexpr->string `((cmd . ,cmd) + (key . ,key) + (params . ,params)))) + (res (begin + (write payload (rmt:conn-outport conn)) + (with-input-from-port + (rmt:conn-inport conn) + read-string)))) (if (string? res) (string->sexpr res) res)))) ;; db is at apath/.db/dbname, rid is an intermediary solution and will be removed