I have run into a problem with the gob encoder doing some funky things that
I do not understand.

Long story short I have two structures that are something like this:
type testA struct {
         T time.Time
         X net.IP
         D []byte
         M map[string]([]byte)

type testB struct {
         X, Y, Z uint64
         Msg []byte

A gob encoder and decoder are held by two clients talking over a

Client A is continually sending testA stucts via the encoder, when he is
done he sends one populated as such genc.Encode(testA{time.Time{}, nil,
nil, nil}), after which it sends a populated structure of type testB
Client B is continually decoding testA until it sees one with D set as nil
or having a length of zero, at which point it expects a structure of type

In this scenario, if the first thing sent by clientA is the mostly nil
testA structure clientB sees it and properly decodes the testB structure.
  However, if clientA has sent a few populated testA structures then sends
the mostly nil testA structure clientB never decodes/sees the nil testA
structure and then fails as it tries to decode the testB structure into a
testA (because clientB doesn't know to stop looking for testA). I have put
together a small code sample that demonstrates this. Anyone have any ideas?

I am about to fire this example up with a TCP connection and wireshark it
to see if the encoder even bothers to send the mostly nil structure, my
next step is to start instrumenting the gob package (but its huge and
nasty). I am hoping I missed something in the docs or am being bone headed.

Thanks for your time

Example Code:

P.S. First time poster so I should say Golang is awesome, it has completely
supplanted all other languages for me other than the really really low
level C/assembly shit.

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

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 3 | next ›
Discussion Overview
groupgolang-nuts @
postedMar 7, '14 at 6:26a
activeMar 8, '14 at 12:50a

2 users in discussion

Traetox: 2 posts Carlos Castillo: 1 post



site design / logo © 2021 Grokbase