0

How do I send an object of type struct tm via byte socket to a server? I know how to send the single bytes of int64_t and others, but afaik time_t depends on the OS where the program is used.

Is there any C++ internal function that can return a known type (for example int64_t) representing a date? Or is it best to create an own format / class, that uses the following code for creation

time_t raw_time;
time(&raw_time);

//UTC zone, because we just need the moment in time and not the timezone
struct tm* ptm = gmtime(&raw_time); 

and calculates an int64_t on its own?

F_Schmidt
  • 902
  • 1
  • 11
  • 32
  • 1
    The jargon for that is serialization or marshalling, the latter's fallen out of use istm. Python calls it "pickling". There's no standard serialization library in C++, google got me [this link](https://isocpp.org/wiki/faq/serialization) – jthill Aug 16 '20 at 14:28
  • "Best practice" is opinion based. Ask ten C++ developers what is the "best practice" for , and you'll get eleven different answers. – Sam Varshavchik Aug 16 '20 at 14:28

0 Answers0