From: Ruediger Meier <ruediger.me...@ga-group.nl>

We have to do this on win32 before doing winsock2 stuff. It affects the
whole application so don't know wheather it's right to startup and clean
it here within the net backend.
---
 backend/net.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/backend/net.c b/backend/net.c
index 0cd7f51..228bd59 100644
--- a/backend/net.c
+++ b/backend/net.c
@@ -1016,6 +1016,18 @@ sane_init (SANE_Int * version_code, SANE_Auth_Callback 
authorize)
       DBG (3, "sane_init: Client has little endian byte order\n");
     }
 
+#ifdef _WIN32
+    {
+      /* no much fun on win32 without WSAStartup but is this the right place? 
*/
+      WSADATA data;
+      int wsa_err = WSAStartup( MAKEWORD(2, 2), &data) != 0;
+      if ( wsa_err != 0 )
+       {
+         DBG (1, "sane_init: WSAStartup failed with error %d\n", wsa_err );
+       }
+    }
+#endif
+
 #ifndef NET_USES_AF_INDEP
   DBG (2, "sane_init: determining sane service port\n");
   serv = getservbyname ("sane-port", "tcp");
@@ -1196,6 +1208,9 @@ sane_exit (void)
        }
       free (devlist);
     }
+#ifdef _WIN32
+  WSACleanup();
+#endif
   DBG (3, "sane_exit: finished.\n");
 }
 
-- 
1.7.6.1


Reply via email to