From c7f7e30c7521bcdafbddd9d21af288442c325a72 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Wed, 26 Jun 2013 09:56:15 -0400 Subject: Moved the network functions from the DHT into network. Also made a nice function to init networking. --- testing/DHT_test.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) (limited to 'testing') 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[]) memcpy(self_client_id, &randdomnum, 4); //memcpy(self_client_id, "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq", 32); - #ifdef WIN32 - WSADATA wsaData; - if(WSAStartup(MAKEWORD(2,2), &wsaData) != NO_ERROR) - { - return -1; - } - #endif - if (argc < 4) { printf("usage %s ip port client_id(of friend to find ip_port of)\n", argv[0]); exit(0); } addfriend(argv[3]); - //initialize our socket - sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - //Set socket nonblocking - #ifdef WIN32 - //I think this works for windows - u_long mode = 1; - //ioctl(sock, FIONBIO, &mode); - ioctlsocket(sock, FIONBIO, &mode); - #else - fcntl(sock, F_SETFL, O_NONBLOCK, 1); - #endif - //Bind our socket to port PORT and address 0.0.0.0 - ADDR addr = {AF_INET, htons(PORT), {{0}}}; - bind(sock, (struct sockaddr*)&addr, sizeof(addr)); + //initialize networking + //bind to ip 0.0.0.0:PORT + IP ip; + ip.i = 0; + init_networking(ip, PORT); + perror("Initialization"); IP_Port bootstrap_ip_port; bootstrap_ip_port.port = htons(atoi(argv[2])); -- cgit v1.2.3