107 lines
1.8 KiB
C++
107 lines
1.8 KiB
C++
#ifndef _SOCKET_WSADATA_HPP_
|
|
#define _SOCKET_WSADATA_HPP_
|
|
#ifndef _COMMON_STRING_HPP_
|
|
#include <common/string.hpp>
|
|
#endif
|
|
#ifndef _COMMON_WINSOCK_HPP_
|
|
#include <common/winsock.hpp>
|
|
#endif
|
|
|
|
class WSASystem
|
|
{
|
|
public:
|
|
WSASystem(void);
|
|
WSASystem(const WSASystem &someWSASystem);
|
|
WSASystem &operator=(const WSASystem &someWSASystem);
|
|
WORD operator==(const WSASystem &someWSASystem);
|
|
virtual ~WSASystem();
|
|
operator WSAData&(void);
|
|
WORD versionLow(void)const;
|
|
WORD versionHigh(void)const;
|
|
String description(void)const;
|
|
String systemStatus(void)const;
|
|
WORD maxSockets(void)const;
|
|
WORD isInitialized(void)const;
|
|
BOOL cancelBlockingCall(void)const;
|
|
BOOL isBlocking(void)const;
|
|
String getLastError(void)const;
|
|
private:
|
|
static WORD smIsInitialized;
|
|
static WORD smInstanceCount;
|
|
static WSADATA smWSAData;
|
|
};
|
|
|
|
inline
|
|
WSASystem::WSASystem(const WSASystem &someWSASystem)
|
|
{
|
|
*this=someWSASystem;
|
|
}
|
|
|
|
inline
|
|
WSASystem::~WSASystem()
|
|
{
|
|
--smInstanceCount;
|
|
if(!smInstanceCount&&smIsInitialized){::WSACleanup();smIsInitialized=FALSE;}
|
|
}
|
|
|
|
inline
|
|
WSASystem &WSASystem::operator=(const WSASystem &/*someWSASystem*/)
|
|
{
|
|
return *this;
|
|
}
|
|
|
|
inline
|
|
WSASystem::operator WSAData&(void)
|
|
{
|
|
return smWSAData;
|
|
}
|
|
|
|
inline
|
|
WORD WSASystem::isInitialized(void)const
|
|
{
|
|
return smIsInitialized;
|
|
}
|
|
|
|
inline
|
|
WORD WSASystem::versionLow(void)const
|
|
{
|
|
return smWSAData.wVersion;
|
|
}
|
|
|
|
inline
|
|
WORD WSASystem::versionHigh(void)const
|
|
{
|
|
return smWSAData.wHighVersion;
|
|
}
|
|
|
|
inline
|
|
String WSASystem::description(void)const
|
|
{
|
|
return smWSAData.szDescription;
|
|
}
|
|
|
|
inline
|
|
String WSASystem::systemStatus(void)const
|
|
{
|
|
return smWSAData.szSystemStatus;
|
|
}
|
|
|
|
inline
|
|
WORD WSASystem::maxSockets(void)const
|
|
{
|
|
return smWSAData.iMaxSockets;
|
|
}
|
|
|
|
inline
|
|
BOOL WSASystem::cancelBlockingCall(void)const
|
|
{
|
|
return !::WSACancelBlockingCall();
|
|
}
|
|
|
|
inline
|
|
BOOL WSASystem::isBlocking(void)const
|
|
{
|
|
return ::WSAIsBlocking();
|
|
}
|
|
#endif
|