diff options
author | irungentoo <irungentoo@gmail.com> | 2013-06-27 07:37:06 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2013-06-27 07:37:06 -0400 |
commit | d0ed1639144a5f3358d8bc69ad0885d0c1133877 (patch) | |
tree | 237e58d3314875939ccd20641a55fb0bfa2d4237 /core/network.c | |
parent | 0068d370ffdb33fe62ab20f3e4654463f469724c (diff) |
Fixed something in the DHT, added a milisecond time function.
Diffstat (limited to 'core/network.c')
-rw-r--r-- | core/network.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/core/network.c b/core/network.c index d5389bfa..70536abf 100644 --- a/core/network.c +++ b/core/network.c | |||
@@ -24,12 +24,26 @@ | |||
24 | 24 | ||
25 | #include "network.h" | 25 | #include "network.h" |
26 | 26 | ||
27 | |||
28 | //returns current time in milleseconds since the epoch. | ||
29 | uint64_t current_time() | ||
30 | { | ||
31 | uint64_t time; | ||
32 | #ifdef WIN32 | ||
33 | //TODO: windows version | ||
34 | #else | ||
35 | struct timeval a; | ||
36 | gettimeofday(&a, NULL); | ||
37 | time = 1000000UL*a.tv_sec + a.tv_usec; | ||
38 | #endif | ||
39 | return time; | ||
40 | |||
41 | } | ||
42 | |||
27 | //our UDP socket, a global variable. | 43 | //our UDP socket, a global variable. |
28 | static int sock; | 44 | static int sock; |
29 | 45 | ||
30 | //Basic network functions: | 46 | //Basic network functions: |
31 | //TODO: put them somewhere else than here | ||
32 | |||
33 | //Function to send packet(data) of length length to ip_port | 47 | //Function to send packet(data) of length length to ip_port |
34 | int sendpacket(IP_Port ip_port, char * data, uint32_t length) | 48 | int sendpacket(IP_Port ip_port, char * data, uint32_t length) |
35 | { | 49 | { |