--- /dev/null
+// Roast+ License
+
+/*
+*/
+#ifndef __SFJP_ROAST__windows__socket_sub_HPP__
+#define __SFJP_ROAST__windows__socket_sub_HPP__
+
+#define ROAST_WINDOWS_SOCKET_DEFAULT_VER_MAJOR (2)
+#define ROAST_WINDOWS_SOCKET_DEFAULT_VER_MINER (0)
+
+//////////////////////////////////////////////////
+
+namespace roast
+{
+ namespace windows
+ {
+ class socket_cleanup
+ {
+ private:
+ static ::WSADATA m_wsaInfo;
+ static int m_count;
+
+ static void startup(
+ unsigned char ver_major=ROAST_WINDOWS_SOCKET_DEFAULT_VER_MAJOR,
+ unsigned char ver_miner=ROAST_WINDOWS_SOCKET_DEFAULT_VER_MINER)
+ {
+ ZeroMemory(&m_wsaInfo,sizeof(m_wsaInfo));
+
+ WORD wVersionRequested = MAKEWORD(ver_major, ver_miner);
+
+ if ( ::WSAStartup(wVersionRequested, &m_wsaInfo) != 0 )
+ throw socket_exception(::WSAGetLastError(), "roast::socket_cleanup::add() ::WSAStartup() function was error.");
+
+ }
+ static void cleanup()
+ {
+ if ( ::WSACleanup() != 0 )
+ throw socket_exception(::WSAGetLastError(), "roast::socket_cleanup::free() ::WSACleanup() function was error.");
+ }
+
+ public:
+ static void add(
+ unsigned char ver_major=ROAST_WINDOWS_SOCKET_DEFAULT_VER_MAJOR,
+ unsigned char ver_miner=ROAST_WINDOWS_SOCKET_DEFAULT_VER_MINER)
+ {
+ if ( m_count == 0 )
+ {
+ startup();
+ }
+ m_count++;
+ }
+
+ static void del()
+ {
+ m_count--;
+ if ( m_count == 0 )
+ {
+ cleanup();
+ }
+ }
+
+ static const ::WSADATA& get_wsadata(){ return m_wsaInfo; }
+ };
+
+ // Static Variables
+ ::WSADATA socket_cleanup::m_wsaInfo;
+ int socket_cleanup::m_count = 0;
+ }
+}
+
+#endif//__SFJP_ROAST__windows__socket_sub_HPP__