I am sending a C structure which looks like this

typdef struct 
{
 unsigned char field1;
 unsigned char field2;
 unsigned char array[10];
}complete_data_t;

I am encoding this data using GOB and sending as UDP broadcast in a very 
small network. On the receiver side, all fields are correctly getting 
parsed but all array elements are coming as zero. I am populating these 
array elements with a non-zero value at the transmitter side.

var data C.complete_data_t

Transmitter side:
var buffer bytes.Buffer
err := gob.NewEncoder(&buffer).Encode(&data)
  _,err = conn.Write(buffer.Bytes())
buffer.Reset()

Receiver side:
rx_buf := make([]byte, 1024)
length,addr,err := conn.ReadFrom(rx_buf)
buffer := bytes.NewBuffer(rx_buf[:length])
err = gob.NewDecoder(buffer).Decode(&data)


  

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to