> It's seems to be sending okay, i've not tried deencoding at the other
> end yet. However when using wireshark, i can see the gob is being
> split over 2 udp packets? however it would seem that the struct i'm
> sending would fit into 1500 byte udp packet?
It's not an issue of gobs per se, it's an issue of how you send them. I
think that on current tip, if you use the rpc package, a gob that is
small enough will now be sent in a single UDP packet rather than in two.
That was a recent change. However, I don't know if there are any
particular guarantees that rpc will continue to work that way.
> * WIll I be able to listen on the other end of the connection and the
> gob decoder is clever enough to works it out?
The gob decoder just wants bytes, so it will work if you feed it streams
of UDP packets.
> * can i control the chunking of the gob encoder?
Of the encoder, no, but that's not what matters here. You can control
the chunking of how the encoder's bytes are written on the wire.
> * is this something to do with path mtu discovery and or udp
> buffering?, is my tcp/udp stack\os breaking it apart?
I doubt it.
> * is it even a good idea to use gob's over the network, never mind
> udp. What's the alternatives?
Gobs work fine over the network.
> my application really needs udp, because it need to be quick! :-)
> without the overhead of a tcp setup.
>
> I'd really like my gob to be sent as one udp packet, (size
> permitting).
Obviously UDP is unreliable delivery, and the whole system is going to
fall apart if a packet is lost. You have to have a very tolerant
application to use UDP in this way.
Ian
To use gob in a context where reordering and loss
can happen you need to create a new gob encoder
for each value, writing to a bytes.Buffer, then encode
the value, then send the buf.Bytes() to the udp connection.
On the other side, create a new gob decoder for each
received packet.
You're giving up some of the benefits of gobs by doing this.
If you can have a long-running tcp connection instead
and the values are small enough that they fit in a single
packet frame anyway, you'll be better off with tcp.
Russ
Gobs will not work on UDP. They are a stream. If a piece of the
stream is dropped that contains a type description, the subsequent
data will not be decodable.
-rob
-rob
-rob
Cheers
Dave
b := bytes.NewBuffer(data)