Questions tagged [timeval]

56 questions
1
vote
3 answers

Strange errors using timeval struct and gettimeofday —because of semicolon in #define

I am getting a couple of weird compilation errors. This is for a homework assignment (help is ok). The idea is to implement a program that tests how well the user can hit "enter" once a second. I'm supposed to use gettimeofday to get some time…
MCP
  • 4,436
  • 12
  • 44
  • 53
0
votes
1 answer

Packet Generation rate measurement in C under Linux

I writing a network program as part of a networking project. The program generates a bunch of packets (TCP used for communication using berkely socket API) and sends it to a particular port and measures the responses that it gets back. The program …
Abdullah
  • 521
  • 2
  • 8
  • 20
0
votes
1 answer

What happens after setsockpt timeval? And how to handle the timeout event? How to get back to the same line of code that was executing before timeout?

When the software is hit by a signal (example: SIGINT), if you previously used signal(SIGINT, SIGINT_HANDLER) (yea, I know signal is evil and all, but just to give the idea) then the software will react this way: the routine f is hit by SIGINT the…
ZODIACK
  • 23
  • 5
0
votes
1 answer

Can I pass a timeval as argument to sleep?

Can I pass a timeval struct as the argument for a sleep function? I want to do this since the timeval struct can get very precise, since you can control the microseconds and I would like to sleep for a certain amount of microseconds. Can I do this?
Serket
  • 3,785
  • 3
  • 14
  • 45
0
votes
0 answers

I need to remove vector elements based on timeval

I have a queue of audio elements for each frame of a movie. I want to remove them from last seen to first seen up to a certain max number of elements. I use timeval to determine the time value. I have problems with the iterators due to calling…
0
votes
1 answer

timeval to uint64_t network bits

I am looking to append timeval fields into my custom packet header. Facing issues with type conversion. My custom fields in the header struct pkthdr { uint64_t sec; uint64_t usec; } Linux timeval struct struct timeval { long tv_sec; …
pgrad13
  • 1
  • 3
0
votes
0 answers

More than one Excel If statement for analysing and receiving a time range

I'm trying to have two cells, so I when I enter midnight (or 0:00) in the first cell I get 8am ( or 8:00) in the second cell. But if I put 8am in the first cell I get 4pm in the second cell. As well as if I put 4pm in the first cell I get midnight…
BlacTeddy
  • 1
  • 2
0
votes
1 answer

How to correctly convert timespec to timeval?

I have a struct timespec object I need to convert to struct timeval for use with lutimes(...). I've attempted the following, but lutimes() complains. const struct timespec ts; // originally provided as function parameter from FUSE struct timeval…
Cobra_Fast
  • 15,671
  • 8
  • 57
  • 102
0
votes
0 answers

Big-endian serialisation of struct timeval

What would be the best way to serialise the struct timeval type obtained via the gettimeofday(2) call? I would like to stick to some standard, so htobe64(3) and friends will not do. The time_t type could possibly be a 64-bit integer and there is no…
Daniel Lovasko
  • 471
  • 2
  • 10
0
votes
2 answers

Add milliseconds to timeval C++

With the code beneath I can get the current time in milliseconds. Now I want to add milliseconds to the systemtime. Any hints? #include #include int main (int argc, char** argv) { struct timeval time; gettimeofday…
Janoshh
  • 19
  • 2
  • 9
0
votes
0 answers

How to set timeval to a random time

I am using libevent to do some tasks after some timeouts, timeouts are randomly selected, and each time they change. The problem is I cannot set timeval variable to a random time. int TIMEOUT = 2000000; // 2 millions micro seconds, which is 2…
MOH
  • 125
  • 1
  • 8
0
votes
1 answer

Using time.h on macos for cross compiler

I want to compile the following code on macos: struct timeval tv; int retval = gettimeofday (&tv, NULL); if (retval == 0) TIMEVAL_TO_TIMESPEC (&tv, tp); //here I am getting the error return retval; But I am getting the error error:…
user3878429
0
votes
4 answers

How do I separately convert a struct timeval into two 32 bit variables?

A struct timeval is 64 bit long. I need, for a project, to convert this long (struct timeval) into two 32 bit chunks, and put each chunk into a different variable. How do I do this? Thanx in advance.
dasen
  • 1
  • 1
0
votes
1 answer

Pass void pointer as function parameter and cast it to timeval array

Assume I have a function calc_sum() and I want to measure its execution time. I have a callback function info_callback() which prints a message and calculates execution time, it takes void pointer as parameter. I want to cast void* to struct timeval…
dr_times
  • 103
  • 5
0
votes
1 answer

Measuring time in C gives wrong result

I am trying to measure time in C in microseconds. I tried this code, but the value time_passed is a huge number, instead of 0 (or 1). struct timeval start; settimeofday(&start,NULL); struct timeval stop; settimeofday(&stop,NULL); …
Charlestone
  • 1,248
  • 1
  • 13
  • 27