workaround for vista service automatic WSAStartup() crash issue

This commit is contained in:
Aleksandar Fabijanic 2010-04-03 14:09:48 +00:00
parent bf87d53ac7
commit 8d928d0c00
2 changed files with 39 additions and 5 deletions

View File

@ -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

View File

@ -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