Go to the documentation of this file.00001 #pragma once
00002
00003 namespace AppSecInc
00004 {
00005 namespace TcpIp
00006 {
00017 class CWSAStartup
00018 {
00019 public:
00021
00022 const static int default_major_version = 2;
00023 const static int default_minor_version = 1;
00024 const static int default_version = MAKEWORD(default_major_version, default_minor_version);
00026
00027 CWSAStartup();
00028 explicit CWSAStartup(WORD version);
00029 CWSAStartup(int major, int minor);
00030 ~CWSAStartup();
00031
00032 bool wasRequestedVersionNegotiated() const;
00033 bool initialized() const;
00034
00035 WORD negotiatedVersion() const;
00036 BYTE negotiatedMajorVersion() const;
00037 BYTE negotiatedMinorVersion() const;
00038 void negotiatedVersion(BYTE& major, BYTE& minor) const;
00039 void negotiatedVersion(int& major, int& minor) const;
00040
00041 WORD highestSupportedVersion() const;
00042 void highestSupportedVersion(WORD& major, WORD& minor) const;
00043 void highestSupportedVersion(int& major, int& minor) const;
00044
00045 int ErrorCode() const;
00046 std::wstring ErrorMessage() const;
00047 const WSADATA& WsaData() const;
00048
00049 static std::wstring ErrorMessage(int errcode);
00050 static BYTE majorVersion(WORD version) { return LOBYTE(version); }
00051 static BYTE minorVersion(WORD version) { return HIBYTE(version); }
00052 static WORD packVersion(BYTE major, BYTE minor) { return MAKEWORD(major, minor); }
00053 static WORD packVersion(int major, int minor) { return MAKEWORD(major, minor); }
00054
00055 private:
00056 void CWSAStartup::init();
00057
00058 CWSAStartup(const CWSAStartup&);
00059 CWSAStartup& operator=(const CWSAStartup&);
00060
00061 bool m_bInitialized;
00062 bool m_bVersionSupported;
00063 int m_rc;
00064 BYTE m_requestedMajorVersion;
00065 BYTE m_requestedMinorVersion;
00066 WSADATA m_wsadata;
00067 };
00068 }
00069 }