Skip to content
Snippets Groups Projects
Commit aad4ad03 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

network utils: add missing includes

parent 3d1e055c
Branches
Tags
No related merge requests found
...@@ -19,6 +19,9 @@ ...@@ -19,6 +19,9 @@
#include "network_utils.h" #include "network_utils.h"
#ifndef _WIN32 #ifndef _WIN32
#include "utils.h"
#include "sockaddr.h"
#include <arpa/inet.h> #include <arpa/inet.h>
#include <unistd.h> #include <unistd.h>
#include <sys/socket.h> #include <sys/socket.h>
...@@ -31,6 +34,8 @@ ...@@ -31,6 +34,8 @@
#endif #endif
#include <fcntl.h> #include <fcntl.h>
#include <string>
namespace dht { namespace dht {
namespace net { namespace net {
...@@ -55,7 +60,7 @@ void udpPipe(int fds[2]) ...@@ -55,7 +60,7 @@ void udpPipe(int fds[2])
{ {
int lst = socket(AF_INET, SOCK_DGRAM, 0); int lst = socket(AF_INET, SOCK_DGRAM, 0);
if (lst < 0) if (lst < 0)
throw DhtException(std::string("Can't open socket: ") + strerror(lst)); throw DhtException(std::string("Can't open socket: ") + strerror(WSAGetLastError()));
sockaddr_in inaddr; sockaddr_in inaddr;
sockaddr addr; sockaddr addr;
memset(&inaddr, 0, sizeof(inaddr)); memset(&inaddr, 0, sizeof(inaddr));
...@@ -68,9 +73,9 @@ void udpPipe(int fds[2]) ...@@ -68,9 +73,9 @@ void udpPipe(int fds[2])
int rc = bind(lst, (sockaddr*)&inaddr, sizeof(inaddr)); int rc = bind(lst, (sockaddr*)&inaddr, sizeof(inaddr));
if (rc < 0) { if (rc < 0) {
close(lst); close(lst);
throw DhtException("Can't bind socket on " + print_addr((sockaddr*)&addr, sizeof(inaddr)) + " " + strerror(rc)); throw DhtException("Can't bind socket on " + print_addr((sockaddr*)&inaddr, sizeof(inaddr)) + " " + strerror(rc));
} }
socklen_t len = sizeof(inaddr); socklen_t len = sizeof(addr);
getsockname(lst, &addr, &len); getsockname(lst, &addr, &len);
fds[0] = lst; fds[0] = lst;
fds[1] = socket(AF_INET, SOCK_DGRAM, 0); fds[1] = socket(AF_INET, SOCK_DGRAM, 0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment