mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-18 00:15:27 +01:00
workaround for vista service automatic WSAStartup() crash issue
This commit is contained in:
parent
bf87d53ac7
commit
8d928d0c00
@ -89,4 +89,22 @@
|
||||
#endif
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Net {
|
||||
|
||||
|
||||
void initializeNetwork();
|
||||
/// Initialize the network subsystem.
|
||||
/// Calls WSAStartup() on Windows, does nothing
|
||||
/// on other platforms.
|
||||
|
||||
void uninitializeNetwork();
|
||||
/// Uninitialize the network subsystem.
|
||||
/// Calls WSACleanup() on Windows, does nothing
|
||||
/// on other platforms.
|
||||
|
||||
|
||||
} } // namespace Poco::Net
|
||||
|
||||
|
||||
#endif // Net_Net_INCLUDED
|
||||
|
@ -50,7 +50,7 @@ using Poco::IOException;
|
||||
//
|
||||
// Automatic initialization of Windows networking
|
||||
//
|
||||
#if defined(_WIN32)
|
||||
#if defined(_WIN32) && !defined(POCO_NET_NO_AUTOMATIC_WSASTARTUP)
|
||||
namespace
|
||||
{
|
||||
class NetworkInitializer
|
||||
@ -58,14 +58,12 @@ namespace
|
||||
public:
|
||||
NetworkInitializer()
|
||||
{
|
||||
WORD version = MAKEWORD(2, 2);
|
||||
WSADATA data;
|
||||
WSAStartup(version, &data);
|
||||
Poco::Net::initializeNetwork();
|
||||
}
|
||||
|
||||
~NetworkInitializer()
|
||||
{
|
||||
WSACleanup();
|
||||
Poco::Net::uninitializeNetwork();
|
||||
}
|
||||
};
|
||||
|
||||
@ -236,4 +234,22 @@ void DNS::error(int code, const std::string& arg)
|
||||
}
|
||||
|
||||
|
||||
void initializeNetwork()
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
WORD version = MAKEWORD(2, 2);
|
||||
WSADATA data;
|
||||
WSAStartup(version, &data);
|
||||
#endif // _WIN32
|
||||
}
|
||||
|
||||
|
||||
void uninitializeNetwork()
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
WSACleanup();
|
||||
#endif // _WIN32
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Net
|
||||
|
Loading…
x
Reference in New Issue
Block a user