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
ReaderWriter.
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
testB.
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:
http://pastebin.com/X0k6ey7w
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 [email protected].
For more options, visit https://groups.google.com/d/optout.