milliseconds on win+linux

  • Thread starter =?ISO-8859-1?Q?Andreas_M=FCller?=
  • Start date
?

=?ISO-8859-1?Q?Andreas_M=FCller?=

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.
 
V

velthuijsen

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.
 
O

osmium

Andreas Müller said:
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.

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,666
Latest member
selsetu

Latest Threads

Top