double GetTimeStamp()
{
struct timespec start;
if((clock_gettime( CLOCK_MONOTONIC, &start)) == -1 )
{
perror("clock gettime\n");
}
return start.tv_sec + start.tv_nsec * 1e-9; //seconds
}
MAIN.c
:
uint64_t Receive;
uint32 receiveTime;
int main()
{
rc=recvfrom(sock, buf, 256, 0, (struct sockaddr*) &client, &len);
Receive = GetTimeStamp();
receiveTime = (uint32) (Receive / 1000000); // I am converting to microseconds
printf("Receive time: %lu\n", receiveTime);
}
I am taking a timestamp and reading that time from another program as shown above. But I am not getting any value if I do as above. Why is it not displaying any value in main?