summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--toxcore/network.c21
1 files changed, 3 insertions, 18 deletions
diff --git a/toxcore/network.c b/toxcore/network.c
index a244b400..75d968be 100644
--- a/toxcore/network.c
+++ b/toxcore/network.c
@@ -307,7 +307,7 @@ Networking_Core *new_networking(IP ip, uint16_t port)
307#else 307#else
308 308
309 if (temp->sock < 0) { 309 if (temp->sock < 0) {
310 fprintf(stderr, "Failed to get a scoket?! %u, %s\n", errno, strerror(errno)); 310 fprintf(stderr, "Failed to get a socket?! %u, %s\n", errno, strerror(errno));
311 free(temp); 311 free(temp);
312 return NULL; 312 return NULL;
313 } 313 }
@@ -474,7 +474,7 @@ Networking_Core *new_networking(IP ip, uint16_t port)
474 474
475 fprintf(stderr, "Failed to bind socket: %u, %s (IP/Port: %s:%u\n", errno, 475 fprintf(stderr, "Failed to bind socket: %u, %s (IP/Port: %s:%u\n", errno,
476 strerror(errno), ip_ntoa(&ip), port); 476 strerror(errno), ip_ntoa(&ip), port);
477 free(temp); 477 kill_networking(temp);
478 return NULL; 478 return NULL;
479} 479}
480 480
@@ -728,25 +728,13 @@ int addr_resolve(const char *address, IP *to, IP *extra)
728 hints.ai_family = family; 728 hints.ai_family = family;
729 hints.ai_socktype = SOCK_DGRAM; // type of socket Tox uses. 729 hints.ai_socktype = SOCK_DGRAM; // type of socket Tox uses.
730 730
731#ifdef __WIN32__ 731 if (at_startup() != 0)
732 WSADATA wsa_data;
733
734 /* CLEANUP: really not the best place to put this */
735 rc = WSAStartup(MAKEWORD(2, 2), &wsa_data);
736
737 if (rc != 0) {
738 return 0; 732 return 0;
739 }
740
741#endif
742 733
743 rc = getaddrinfo(address, NULL, &hints, &server); 734 rc = getaddrinfo(address, NULL, &hints, &server);
744 735
745 // Lookup failed. 736 // Lookup failed.
746 if (rc != 0) { 737 if (rc != 0) {
747#ifdef __WIN32__
748 WSACleanup();
749#endif
750 return 0; 738 return 0;
751 } 739 }
752 740
@@ -823,9 +811,6 @@ int addr_resolve(const char *address, IP *to, IP *extra)
823 811
824 812
825 freeaddrinfo(server); 813 freeaddrinfo(server);
826#ifdef __WIN32__
827 WSACleanup();
828#endif
829 return rc; 814 return rc;
830} 815}
831 816