Connecting Tech Pros Worldwide Help | Site Map

milliseconds on win+linux

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 23rd, 2005, 03:57 AM
Andreas Müller
Guest
 
Posts: n/a
Default milliseconds on win+linux

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.

  #2  
Old July 23rd, 2005, 03:57 AM
velthuijsen@hotmail.com
Guest
 
Posts: n/a
Default 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.

  #3  
Old July 23rd, 2005, 03:57 AM
wittempj@hotmail.com
Guest
 
Posts: n/a
Default Re: milliseconds on win+linux

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

  #4  
Old July 23rd, 2005, 03:57 AM
wittempj@hotmail.com
Guest
 
Posts: n/a
Default Re: milliseconds on win+linux

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

  #5  
Old July 23rd, 2005, 03:57 AM
osmium
Guest
 
Posts: n/a
Default 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.


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.