diff -u -x *~ -r pan-0.112/pan/tasks/socket-impl-gio.cc pandev/pan/tasks/socket-impl-gio.cc
--- pan-0.112/pan/tasks/socket-impl-gio.cc	Fri Sep  8 12:25:08 2006
+++ pandev/pan/tasks/socket-impl-gio.cc	Sun Sep 10 23:42:12 2006
@@ -91,15 +91,61 @@
 
 namespace 
 {
+  typedef int (*t_getaddrinfo)(const char *,const char *, const struct addrinfo*, struct addrinfo **);
+  typedef void (*t_freeaddrinfo)(struct addrinfo*);
+  t_getaddrinfo p_getaddrinfo=NULL;
+  t_freeaddrinfo p_freeaddrinfo=NULL;
+  
   void ensure_module_inited (void)
   {
     static bool inited (false);
 
     if (!inited)
     {
+      p_freeaddrinfo=NULL;
+      p_getaddrinfo=NULL;
+      
 #ifdef G_OS_WIN32
       WSADATA wsaData;
       WSAStartup(MAKEWORD(2,2), &wsaData);
+      
+      char sysdir[MAX_PATH], path[MAX_PATH+8];
+      
+      if(GetSystemDirectory(sysdir,MAX_PATH)!=0)
+      {
+        HMODULE lib=NULL;
+        FARPROC pfunc=NULL;
+        const char *libs[]={"ws2_32","wship6",NULL};
+        
+        for(const char **p=libs;*p!=NULL;++p)
+        {
+          g_snprintf(path,MAX_PATH+8,"%s\\%s",sysdir,*p);
+          lib=LoadLibrary(path);
+          if(!lib)
+            continue;
+          pfunc=GetProcAddress(lib,"getaddrinfo");
+          if(!pfunc)
+          {
+            FreeLibrary(lib);
+            lib=NULL;
+            continue;
+          }
+          p_getaddrinfo=reinterpret_cast<t_getaddrinfo>(pfunc);
+          pfunc=GetProcAddress(lib,"freeaddrinfo");
+          if(!pfunc)
+          {
+            FreeLibrary(lib);
+            lib=NULL;
+            p_getaddrinfo=NULL;
+            continue;
+          }
+          p_freeaddrinfo=reinterpret_cast<t_freeaddrinfo>(pfunc);
+          break;
+        }
+      }
+#else
+      p_freeaddrinfo=::freeaddrinfo;
+      p_getaddrinfo=::getaddrinfo;
 #endif
       inited = true;
     }
@@ -110,7 +156,6 @@
   {
     int err;
     int sockfd;
-    ensure_module_inited ();
 
 #ifndef G_OS_WIN32
     signal (SIGPIPE, SIG_IGN);
@@ -122,9 +167,8 @@
     g_snprintf (hostbuf, sizeof(hostbuf), "%*.*s", host.len, host.len, host.str);
     g_snprintf (portbuf, sizeof(portbuf), "%d", port);
 
-#if defined(G_OS_WIN32) && _WIN32_WINNT <= 0x0500
-#warning "Compiling in backward compatibility mode, may lead to problems"
-
+  if(p_getaddrinfo==NULL)
+  {
     struct hostent * ans = isalpha (hostbuf[0])
       ? gethostbyname (hostbuf)
       : gethostbyaddr (hostbuf, host.len, AF_INET);
@@ -169,16 +213,15 @@
       PrintLastError(err);
       return NULL;
     }
-
-#else	
-
+  }else
+  {
     struct addrinfo hints;
     memset (&hints, 0, sizeof(struct addrinfo));
     hints.ai_flags = 0;
     hints.ai_family = 0;
     hints.ai_socktype = SOCK_STREAM;
     struct addrinfo * ans;
-    err = ::getaddrinfo (hostbuf, portbuf, &hints, &ans);
+    err = p_getaddrinfo (hostbuf, portbuf, &hints, &ans);
     if (err != 0) {
       g_message ("Lookup error: %s", gai_strerror(err));
       return NULL;
@@ -204,10 +247,9 @@
         sockfd = -1;
       }
     }
-    ::freeaddrinfo (ans);
-
-#endif
+    p_freeaddrinfo (ans);
 
+  }
     GIOChannel * channel (0);
     if (sockfd < 0)
       g_message ("couldn't create a socket.");
@@ -278,7 +320,8 @@
 bool
 GIOChannelSocket :: open (const StringView& address, int port)
 {
-  _channel = create_channel (address, port);
+     ensure_module_inited ();
+ _channel = create_channel (address, port);
   return _channel != 0;
 }
 
@@ -539,6 +582,7 @@
                                               int                port,
                                               Listener         * listener)
 {
+    ensure_module_inited ();
   // farm this out to a worker thread so that the main thread
   // doesn't block while we open the socket.
   g_thread_create (create_socket_thread_func,
