Connecting Tech Pros Worldwide Forums | Help | Site Map

milliseconds on win+linux

Andreas Müller
Guest
 
Posts: n/a
#1: Jul 23 '05
I need a time function like gettimeofday() (for milliseconds) that works
on both, win and linux.
I also need the value of it in a char array, I even don't know how to
convert it from gettimeofday()...
can anybody help me?

I need it for a timestamping function that marks a packet on a windows
system with a timestamp. On the Linux client I need this timestamp to
compute some stuff.

velthuijsen@hotmail.com
Guest
 
Posts: n/a
#2: Jul 23 '05

re: milliseconds on win+linux


try the header ctime it is defined as a standard header file and as
such has the best chances of getting everyting you want.
And even then you might have to build your own functions out of the std
ones. Seeing that they only way you can get milliseconds out of the
system is by using clock() and that only counts from when the process
started (that calls clock()).
For the rest there are no shared functions for time AFAIK.

wittempj@hotmail.com
Guest
 
Posts: n/a
#3: Jul 23 '05

re: milliseconds on win+linux


a quick example for ctime functions is here:
http://www.cplusplus.com/ref/ctime/asctime.html

wittempj@hotmail.com
Guest
 
Posts: n/a
#4: Jul 23 '05

re: milliseconds on win+linux


a quick example for ctime functions is here:
http://www.cplusplus.com/ref/ctime/asctime.html

osmium
Guest
 
Posts: n/a
#5: Jul 23 '05

re: milliseconds on win+linux


"Andreas Müller" writes:
[color=blue]
>I need a time function like gettimeofday() (for milliseconds) that works on
>both, win and linux.
> I also need the value of it in a char array, I even don't know how to
> convert it from gettimeofday()...
> can anybody help me?
>
> I need it for a timestamping function that marks a packet on a windows
> system with a timestamp. On the Linux client I need this timestamp to
> compute some stuff.[/color]

As far as I know you will have to attack this as two separate problems. How
to get a millisecond time stamp from Windows. How to get a millisecond time
stamp from Linux. Then when you compile, include the appropriate code. I
would browse the newsgroups for Linux and Windows for an answer already
posted, after all it is a thing a lot of people want to do.


Closed Thread