0

Hi,

I have a struct that looks like this

struct Info
{
  char **field_names;
  double **data;
  int *cindex;
}

I have to serialize an object of this struct and send it over a socket and deserialize at the other end. What is the best option for this?

Edited by AutoC: n/a

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by Ancient Dragon
0

That has two two-dimensional arrays of unknown sizes, and a one-dimensional array of unknown size. How does the program that uses that structure know their dimensions? Without knowing the dimensions it will be impossible to serialize it anywhere, much less actually use it for anything.

Edited by Ancient Dragon: n/a

0

I define them dynamically inside the program before I have to send

0

Each of those arrays have to be serialized individually as if they were not part of a structure. Serializing just the structure is useless. You need to preceed each string with its length so that the receiving computer program knows how much data to expect and how to reconstruct the arrays and structure.

Serializing to a serial port is exactly identical to writing it to a text file. I'd serialize it to a text file first to get the algorithms down then change the stream to a serial port.

Edited by Ancient Dragon: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.