enable IPv4/IPv6 dual-stack
This commit is contained in:
parent
98231b02a5
commit
b09b5c0ed0
3 changed files with 12 additions and 3 deletions
YSFReflector
|
@ -1,6 +1,6 @@
|
||||||
CC = cc
|
CC = cc
|
||||||
CXX = c++
|
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
|
LIBS = -lpthread
|
||||||
LDFLAGS = -g
|
LDFLAGS = -g
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,8 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
CNetwork::CNetwork(unsigned int port, unsigned int id, const std::string& name, const std::string& description, bool debug) :
|
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_id(id),
|
||||||
m_name(name),
|
m_name(name),
|
||||||
m_description(description),
|
m_description(description),
|
||||||
|
@ -49,7 +50,14 @@ bool CNetwork::open()
|
||||||
{
|
{
|
||||||
LogInfo("Opening YSF network connection");
|
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)
|
bool CNetwork::writeData(const unsigned char* data, const sockaddr_storage& addr, unsigned int addrLen)
|
||||||
|
|
|
@ -44,6 +44,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CUDPSocket m_socket;
|
CUDPSocket m_socket;
|
||||||
|
unsigned short m_port;
|
||||||
unsigned int m_id;
|
unsigned int m_id;
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
std::string m_description;
|
std::string m_description;
|
||||||
|
|
Loading…
Add table
Reference in a new issue