You can send as you like, as long as on the receiving side you can restore the original value. You can even double , representing the number of hours, but the easiest way to do this is by using integer int (or even uint ) numbers, so there are less chances to run into some rounding errors and other problems of incompatibility of floating-point representations (although for the most part still rely everywhere on IEEE-754 ).
If the time interval is converted to an integer that corresponds to a count of seconds (if greater accuracy is needed, for example, milliseconds, the whole type can be expanded), then after translation, following the byte order and transmission over the network at the receiving (C ++) side, you can write something like (assuming that the number was placed in a 32-bit unsigned int ):
#include <cstdint> std::uint32_t sec = 0; if (sizeof(sec) != recv(sockfd, &sec, sizeof(sec), 0)) { // в sec получено кол-во секунд }
As an alternative, which will exclude the influence of the order of bytes, you can offer the transmission of the interval as a string, for example "12:34:56" . However, in this case, the size of the transmitted data will increase, however, it will be easier to receive and transmit such a string between different architectures that can participate in the exchange over the network.
TimeSpanuniquely determined by onelongvalue (Ticks); you can transmit it. Or, if this is redundant for you, just pass an integer number of seconds - Andrey NOPlong Tickstohh:mm:ssformat? - Andrei Khotko