1
0
Fork 0

enable IPv4/IPv6 dual-stack

ycs232-kbc
SASANO Takayoshi 4 years ago
parent 98231b02a5
commit b09b5c0ed0

@ -1,6 +1,6 @@
CC = cc
CXX = c++
CFLAGS = -g -O3 -Wall -std=c++0x -pthread
CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DHAVE_LOG_H -DUDP_SOCKET_MAX=2
LIBS = -lpthread
LDFLAGS = -g

@ -26,7 +26,8 @@
#include <cstring>
CNetwork::CNetwork(unsigned int port, unsigned int id, const std::string& name, const std::string& description, bool debug) :
m_socket(port),
m_socket(),
m_port(port),
m_id(id),
m_name(name),
m_description(description),
@ -49,7 +50,14 @@ bool CNetwork::open()
{
LogInfo("Opening YSF network connection");
return m_socket.open();
bool status = false;
unsigned int af[] = {AF_INET, AF_INET6};
for (int i = 0; i < UDP_SOCKET_MAX &&
i < (sizeof(af) / sizeof(unsigned int)); i++)
status |= m_socket.open(i, af[i], "", m_port);
return status;
}
bool CNetwork::writeData(const unsigned char* data, const sockaddr_storage& addr, unsigned int addrLen)

@ -44,6 +44,7 @@ public:
private:
CUDPSocket m_socket;
unsigned short m_port;
unsigned int m_id;
std::string m_name;
std::string m_description;

Loading…
Cancel
Save