Re: Getting -ve timestamp values.
- From: "B. Augestad" <boa@xxxxxxxxxxxxxx>
- Date: Sun, 08 Apr 2007 11:15:32 +0200
jdthebigj@xxxxxxxxx wrote:
I am not a very good unix programmer. I'm trying to get timestamps for[snip]
my packets. I tried using the SO_TIMESTAMP flag for obtaining the time
stamp. But it is returning me -ve timestamps. Can you tell me what the
problem is in my code. I checked the system date and time and it is
absolutely correct.
time = ctime(&ts);
printf("Received: %s at time: %d = %s",&msg,ts,time);
I have no idea what you mean by "-ve", but assume that you mean "negative". If so, work on your spelling.
Anyway, time_t is not a signed type, it is unsigned. To print it, use %lu and cast the value to (unsigned long).
printf("Received: %s at time: %lu = %s",&msg,(unsigned long)ts,time);
HTH
Bjørn
[snip]
--
Looking for an embeddable web server?
http://www.metasystems.no/products/highlander/index.html
.
- Follow-Ups:
- Re: Getting -ve timestamp values.
- From: Geoff Clare
- Re: Getting -ve timestamp values.
- References:
- Getting -ve timestamp values.
- From: jdthebigj
- Getting -ve timestamp values.
- Prev by Date: Getting -ve timestamp values.
- Next by Date: Re: Is "A/A USB Direct Cable Connection driver" possible?
- Previous by thread: Getting -ve timestamp values.
- Next by thread: Re: Getting -ve timestamp values.
- Index(es):
Relevant Pages
|