Re: check if a variable is time_t
- From: Måns Rullgård <mans@xxxxxxxxx>
- Date: Tue, 26 Jun 2007 22:13:26 +0100
Eric Sosman <Eric.Sosman@xxxxxxx> writes:
Pietro Cerutti wrote On 06/26/07 15:34,:
Eric Sosman wrote:
[...]
You've got a (potentially) worse problem, though. If
the computer on the other side of the network is not the
same kind as yours or is running a different O/S, its time_t
representation may be different from yours. Even if both
are POSIX systems that count seconds since the Epoch, you
still need to take care of endianness -- of representation
issues in general. You would be *much* better off using a
text format for over-the-network exchanges between what
might be dissimilar machines. You don't need to go all the
way through strftime on output and strptime on input; even
a digit string representing a plain seconds count would
avoid a good deal of trouble.
What about using htonl and ntohl on the value before sending /
after receiving it?
You could do that, if you assume time_t is 32 bits
on both systems. If you encounter a machine where time_t
is 64 bits (one suggested cure for "the 2038 bug"), you'll
still have trouble.
Most 64-bit systems have a 64-bit time_t, and they're getting quite
common these days.
--
Måns Rullgård
mans@xxxxxxxxx
.
- References:
- check if a variable is time_t
- From: Pietro Cerutti
- Re: check if a variable is time_t
- From: Måns Rullgård
- Re: check if a variable is time_t
- From: Pietro Cerutti
- Re: check if a variable is time_t
- From: Eric Sosman
- Re: check if a variable is time_t
- From: Pietro Cerutti
- Re: check if a variable is time_t
- From: Eric Sosman
- check if a variable is time_t
- Prev by Date: Re: yacc question
- Next by Date: Re: check if a variable is time_t
- Previous by thread: Re: check if a variable is time_t
- Next by thread: Re: check if a variable is time_t
- Index(es):
Relevant Pages
|