Init winsock at application init, not on first socket use.

This commit is contained in:
Bartosz Taudul 2017-09-14 02:13:45 +02:00
parent a159b70d40
commit ef7dca9073

View File

@ -19,12 +19,10 @@ namespace tracy
{
#ifdef _MSC_VER
static bool initDone = false;
static void InitWinSock()
struct __wsinit
{
if( !initDone )
__wsinit()
{
initDone = true;
WSADATA wsaData;
if( WSAStartup( MAKEWORD( 2, 2 ), &wsaData ) != 0 )
{
@ -32,23 +30,17 @@ static void InitWinSock()
exit( 1 );
}
}
}
} ___wsinit;
#endif
Socket::Socket()
: m_sock( -1 )
{
#ifdef _MSC_VER
InitWinSock();
#endif
}
Socket::Socket( int sock )
: m_sock( sock )
{
#ifdef _MSC_VER
assert( initDone );
#endif
}
Socket::~Socket()
@ -179,9 +171,6 @@ bool Socket::HasData()
ListenSocket::ListenSocket()
: m_sock( -1 )
{
#ifdef _MSC_VER
InitWinSock();
#endif
}
ListenSocket::~ListenSocket()