mirror of
https://github.com/g4klx/DMRGateway
synced 2025-12-21 13:35:40 +08:00
Fix Windows.
This commit is contained in:
@@ -190,6 +190,8 @@ m_rxFrequency(0U)
|
|||||||
,m_gpsd(NULL)
|
,m_gpsd(NULL)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
CUDPSocket::startup();
|
||||||
|
|
||||||
m_status = new DMRGW_STATUS[3U];
|
m_status = new DMRGW_STATUS[3U];
|
||||||
m_status[1U] = DMRGWS_NONE;
|
m_status[1U] = DMRGWS_NONE;
|
||||||
m_status[2U] = DMRGWS_NONE;
|
m_status[2U] = DMRGWS_NONE;
|
||||||
@@ -267,6 +269,8 @@ CDMRGateway::~CDMRGateway()
|
|||||||
|
|
||||||
delete[] m_status;
|
delete[] m_status;
|
||||||
delete[] m_config;
|
delete[] m_config;
|
||||||
|
|
||||||
|
CUDPSocket::shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
int CDMRGateway::run()
|
int CDMRGateway::run()
|
||||||
|
|||||||
@@ -37,12 +37,6 @@ m_address_save(address),
|
|||||||
m_port_save(port),
|
m_port_save(port),
|
||||||
m_counter(0U)
|
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++) {
|
for (int i = 0; i < UDP_SOCKET_MAX; i++) {
|
||||||
m_address[i] = "";
|
m_address[i] = "";
|
||||||
m_port[i] = 0U;
|
m_port[i] = 0U;
|
||||||
@@ -56,12 +50,6 @@ m_address_save(),
|
|||||||
m_port_save(port),
|
m_port_save(port),
|
||||||
m_counter(0U)
|
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++) {
|
for (int i = 0; i < UDP_SOCKET_MAX; i++) {
|
||||||
m_address[i] = "";
|
m_address[i] = "";
|
||||||
m_port[i] = 0U;
|
m_port[i] = 0U;
|
||||||
@@ -72,6 +60,20 @@ m_counter(0U)
|
|||||||
|
|
||||||
CUDPSocket::~CUDPSocket()
|
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)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
::WSACleanup();
|
::WSACleanup();
|
||||||
#endif
|
#endif
|
||||||
@@ -293,7 +295,6 @@ int CUDPSocket::read(unsigned char* buffer, unsigned int length, sockaddr_storag
|
|||||||
|
|
||||||
m_counter++;
|
m_counter++;
|
||||||
address_length = size;
|
address_length = size;
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,9 @@ public:
|
|||||||
void close();
|
void close();
|
||||||
void close(const unsigned int index);
|
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);
|
||||||
static int lookup(const std::string& hostName, unsigned int port, sockaddr_storage& address, unsigned int& address_length, struct addrinfo& hints);
|
static int lookup(const std::string& hostName, unsigned int port, sockaddr_storage& address, unsigned int& address_length, struct addrinfo& hints);
|
||||||
|
|
||||||
@@ -78,4 +81,3 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user