summaryrefslogtreecommitdiff
path: root/core/network.c
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2013-06-27 07:37:06 -0400
committerirungentoo <irungentoo@gmail.com>2013-06-27 07:37:06 -0400
commitd0ed1639144a5f3358d8bc69ad0885d0c1133877 (patch)
tree237e58d3314875939ccd20641a55fb0bfa2d4237 /core/network.c
parent0068d370ffdb33fe62ab20f3e4654463f469724c (diff)
Fixed something in the DHT, added a milisecond time function.
Diffstat (limited to 'core/network.c')
-rw-r--r--core/network.c18
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.
29uint64_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.
28static int sock; 44static 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
34int sendpacket(IP_Port ip_port, char * data, uint32_t length) 48int sendpacket(IP_Port ip_port, char * data, uint32_t length)
35{ 49{