summaryrefslogtreecommitdiff
path: root/testing/DHT_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'testing/DHT_test.c')
-rw-r--r--testing/DHT_test.c28
1 files changed, 6 insertions, 22 deletions
diff --git a/testing/DHT_test.c b/testing/DHT_test.c
index 53712e6e..03a49a3e 100644
--- a/testing/DHT_test.c
+++ b/testing/DHT_test.c
@@ -87,35 +87,19 @@ int main(int argc, char *argv[])
87 memcpy(self_client_id, &randdomnum, 4); 87 memcpy(self_client_id, &randdomnum, 4);
88 //memcpy(self_client_id, "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq", 32); 88 //memcpy(self_client_id, "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq", 32);
89 89
90 #ifdef WIN32
91 WSADATA wsaData;
92 if(WSAStartup(MAKEWORD(2,2), &wsaData) != NO_ERROR)
93 {
94 return -1;
95 }
96 #endif
97
98 if (argc < 4) { 90 if (argc < 4) {
99 printf("usage %s ip port client_id(of friend to find ip_port of)\n", argv[0]); 91 printf("usage %s ip port client_id(of friend to find ip_port of)\n", argv[0]);
100 exit(0); 92 exit(0);
101 } 93 }
102 addfriend(argv[3]); 94 addfriend(argv[3]);
103 95
104 //initialize our socket
105 sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
106 //Set socket nonblocking
107 #ifdef WIN32
108 //I think this works for windows
109 u_long mode = 1;
110 //ioctl(sock, FIONBIO, &mode);
111 ioctlsocket(sock, FIONBIO, &mode);
112 #else
113 fcntl(sock, F_SETFL, O_NONBLOCK, 1);
114 #endif
115 96
116 //Bind our socket to port PORT and address 0.0.0.0 97 //initialize networking
117 ADDR addr = {AF_INET, htons(PORT), {{0}}}; 98 //bind to ip 0.0.0.0:PORT
118 bind(sock, (struct sockaddr*)&addr, sizeof(addr)); 99 IP ip;
100 ip.i = 0;
101 init_networking(ip, PORT);
102
119 perror("Initialization"); 103 perror("Initialization");
120 IP_Port bootstrap_ip_port; 104 IP_Port bootstrap_ip_port;
121 bootstrap_ip_port.port = htons(atoi(argv[2])); 105 bootstrap_ip_port.port = htons(atoi(argv[2]));