1
0
Fork 0

Get the DG-Id Gateway to run under Windows.

ycs232-kbc
Jonathan Naylor 4 years ago
parent c215f814e0
commit 49c8b0f41a

@ -92,10 +92,12 @@ m_conf(configFile),
m_writer(NULL),
m_gps(NULL)
{
CUDPSocket::startup();
}
CDGIdGateway::~CDGIdGateway()
{
CUDPSocket::shutdown();
}
int CDGIdGateway::run()

@ -37,12 +37,6 @@ m_address_save(address),
m_port_save(port),
m_counter(0U)
{
#if defined(_WIN32) || defined(_WIN64)
WSAData data;
int wsaRet = ::WSAStartup(MAKEWORD(2, 2), &data);
if (wsaRet != 0)
LogError("Error from WSAStartup");
#endif
for (int i = 0; i < UDP_SOCKET_MAX; i++) {
m_address[i] = "";
m_port[i] = 0U;
@ -56,12 +50,6 @@ m_address_save(),
m_port_save(port),
m_counter(0U)
{
#if defined(_WIN32) || defined(_WIN64)
WSAData data;
int wsaRet = ::WSAStartup(MAKEWORD(2, 2), &data);
if (wsaRet != 0)
LogError("Error from WSAStartup");
#endif
for (int i = 0; i < UDP_SOCKET_MAX; i++) {
m_address[i] = "";
m_port[i] = 0U;
@ -72,6 +60,20 @@ m_counter(0U)
CUDPSocket::~CUDPSocket()
{
}
void CUDPSocket::startup()
{
#if defined(_WIN32) || defined(_WIN64)
WSAData data;
int wsaRet = ::WSAStartup(MAKEWORD(2, 2), &data);
if (wsaRet != 0)
LogError("Error from WSAStartup");
#endif
}
void CUDPSocket::shutdown()
{
#if defined(_WIN32) || defined(_WIN64)
::WSACleanup();
#endif

@ -61,8 +61,12 @@ public:
void close();
void close(const unsigned int index);
static void startup();
static void shutdown();
static int lookup(const std::string& hostName, unsigned int port, sockaddr_storage& address, unsigned int& address_length);
static int lookup(const std::string& hostName, unsigned int port, sockaddr_storage& address, unsigned int& address_length, struct addrinfo& hints);
static bool match(const sockaddr_storage& addr1, const sockaddr_storage& addr2, IPMATCHTYPE type = IMT_ADDRESS_AND_PORT);
static bool isNone(const sockaddr_storage& addr);

Loading…
Cancel
Save