With a helpful pointer from Dupéron Georges I found the
protocol-buffer compiler and managed to create the messages I needed.
I have things working now, but one (hopefully final) issue:  I can
serialize any message I want, send it through a port, and deserialize
it on the other end, but so far I have not been able to send multiple
messages through one port.

Code is below.  I'm running it like this:

$ racket serialize.rkt | racket deserialize.rkt

If I serialize two different types of messages then the error message I get is:
stdin::95: deserialize: wire type does not match declared type: 'int*

If I serialize two of the same message type then I get:
deserialize: missing required fields: (seteqv 1)

I think what's happening is that deserialize is reading the entire
input buffer and assuming that all of it fits into one message.  I'm
wondering if anyone knows a way around that?

;;    In 'serialize.rkt'
(define c1 (announce-file:announce-chunks* #:chunk-hash "c1 hash"
#:chunk-size-mb 2))
(define c2 (announce-file:announce-chunks* #:chunk-hash "c2 hash"
#:chunk-size-mb 2))
(define f (announce-file* #:chunk (list c1 c2)))

(serialize c1)
(serialize c2)
(serialize f) ;; comment this line out to make the eventual error message change

;; In 'deserialize.rkt'
(announce-file:announce-chunks-chunk-hash (deserialize
(announce-file:announce-chunks-chunk-hash (deserialize
(announce-file-chunk (deserialize (announce-file*))) ;; comment this
line out to make the eventual error message change

;; The message definitions:
 ((optional primitive:int32 version 1 1)
  (optional primitive:bool authenticated 3 #f)
  (optional primitive:string file-hash 4)
  (optional primitive:string file-path 5)
  (optional primitive:int64 file-modified 6 0)
  (optional primitive:int64 file-size-mb 7)
  (repeated struct:announce-file:announce-chunks chunk 8)))

 ((required primitive:string chunk-hash 1)
  (optional primitive:int64 chunk-size-mb 2)))

You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to