Megatest

Check-in [e69f5bdf52]
Login
Overview
Comment:Send plain text sexprs instead of pkts
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.65-multi-db
Files: files | file ages | folders
SHA1: e69f5bdf52f9b9757fc8db839951fa114296d6b4
User & Date: mrwellan on 2019-02-06 15:18:36
Other Links: branch diff | manifest | tags
Context
2019-02-06
16:47
Full communication loop seems to be working. check-in: 13061daea9 user: mrwellan tags: v1.65-multi-db
15:18
Send plain text sexprs instead of pkts check-in: e69f5bdf52 user: mrwellan tags: v1.65-multi-db
10:56
Got basic communication connection up check-in: e7f8564371 user: mrwellan tags: v1.65-multi-db
Changes

Modified megatest.scm from [273489d1a3] to [e83d84bbae].

315
316
317
318
319
320
321

322
323
324
325
326
327
328
			":units"
			;; misc
			"-start-dir"
                        "-run-patt"
                        "-target-patt"   
			"-contour"
                        "-area-tag"  

			"-server"
			"-transport"
			"-port"
			"-extract-ods"
			"-pathmod"
			"-env2file"
			"-envcap"







>







315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
			":units"
			;; misc
			"-start-dir"
                        "-run-patt"
                        "-target-patt"   
			"-contour"
                        "-area-tag"  
                        "-area"  
			"-server"
			"-transport"
			"-port"
			"-extract-ods"
			"-pathmod"
			"-env2file"
			"-envcap"

Modified server.scm from [ca7c30c893] to [4571e1a825].

158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
(define (server:launch mode proc)
  (let* ((start-time (current-seconds))
	 (rep        (server:start-nmsg mode))
	 (last-msg   (current-seconds))
	 (th1        (make-thread
		      (lambda ()
			(let loop ()
			  (let ((pktdat (nmsg:recv rep)))
			    (set! last-msg (current-seconds))
			    (print "received: " pktdat)
			    (if (not (eof-object? pktdat))
				(begin
				  (proc pktdat)
				  (loop))))))
		      "message handler"))
	 (th2       (make-thread
		     (lambda ()







|

|







158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
(define (server:launch mode proc)
  (let* ((start-time (current-seconds))
	 (rep        (server:start-nmsg mode))
	 (last-msg   (current-seconds))
	 (th1        (make-thread
		      (lambda ()
			(let loop ()
			  (let ((pktdat (server:receive rep)))
			    (set! last-msg (current-seconds))
			    ;; (print "received: " pktdat)
			    (if (not (eof-object? pktdat))
				(begin
				  (proc pktdat)
				  (loop))))))
		      "message handler"))
	 (th2       (make-thread
		     (lambda ()
219
220
221
222
223
224
225


226
227
228
229
230
231
232



233
234
235
236
237
238








239
240
241
242
243
244
245
	 (host   (alist-ref 'hostname servpkt))
	 (ip     (alist-ref 'ip       servpkt))
	 (hkey   (alist-ref 'Z        servpkt))
	 (addr   (conc (or ip host) ":" port)) ;; fall back to host if ip not provided
	 (myport (area-port *area-info*))
	 (myhost (area-myaddr *area-info*))
	 (mykey  (area-pktid  *area-info*))


	 (msg    (alist->pkt `((hostname . ,myhost)
			       (port     . ,myport)
			       (servkey  . ,hkey)     ;; server looks at this to ensure message is for them
			       (hostkey  . ,mykey)
			       (format   . ,dtype)    ;; formating of the message
			       (data     . ,data))
			     *pktspec*)))



    (if (and port host)
	(begin
	  (print "sending " msg " to " addr)
	  (nmsg:open-send-receive addr msg))
	#f)))









;; is the server alive?
;;
(define (server:ping servpkt)
  (let* ((start-time (current-milliseconds))
	 (res        (server:send servpkt "ping" "t")))
    (cons (- (current-milliseconds) start-time)
	  (equal? res "got ping"))))







>
>
|
|
|
|
|
|
|
>
>
>






>
>
>
>
>
>
>
>







219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
	 (host   (alist-ref 'hostname servpkt))
	 (ip     (alist-ref 'ip       servpkt))
	 (hkey   (alist-ref 'Z        servpkt))
	 (addr   (conc (or ip host) ":" port)) ;; fall back to host if ip not provided
	 (myport (area-port *area-info*))
	 (myhost (area-myaddr *area-info*))
	 (mykey  (area-pktid  *area-info*))
	 (msg    (with-output-to-string
		   (lambda ()
		     (write `((hostname . ,myhost)
			      (port     . ,myport)
			      (servkey  . ,hkey)     ;; server looks at this to ensure message is for them
			      (hostkey  . ,mykey)
			      (format   . ,dtype)    ;; formating of the message
			      (data     . ,data))
			    ;; *pktspec*
			    ;; ptype: 'data))
			    )))))
    (print "msg: " msg)
    (if (and port host)
	(begin
	  (print "sending " msg " to " addr)
	  (nmsg:open-send-receive addr msg))
	#f)))

;; get the response
;;
(define (server:receive rep)
  (let ((instr (nmsg:recv rep)))
    (if (string? instr)
	(with-input-from-string instr read)
	instr)))
	 
;; is the server alive?
;;
(define (server:ping servpkt)
  (let* ((start-time (current-milliseconds))
	 (res        (server:send servpkt "ping" "t")))
    (cons (- (current-milliseconds) start-time)
	  (equal? res "got ping"))))