+// --------------------------------------------------------------------------
+// Initialization and shutdown
+// --------------------------------------------------------------------------
+
+// FIXME-MT: all this is MT-unsafe, of course, we should protect all accesses
+// to m_countInit with a crit section
+size_t wxSocketBase::m_countInit = 0;
+
+bool wxSocketBase::IsInitialized()
+{
+ return m_countInit > 0;
+}
+
+bool wxSocketBase::Initialize()
+{
+ if ( !m_countInit++ )
+ {
+ if ( !GSocket_Init() )
+ {
+ m_countInit--;
+
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+void wxSocketBase::Shutdown()
+{
+ // we should be initialized
+ wxASSERT_MSG( m_countInit, _T("extra call to Shutdown()") );
+ if ( !--m_countInit )
+ {
+ GSocket_Cleanup();
+ }
+}
+