Check the error status of connect() in a Windows-specific way.  Also, do not
pass a NULL pointer to ioctlsocket().  Thanks to Sebastiaan Ardaseer for
reporting the bug and testing the fixes.

Signed-off-by: Scott Talbert <s...@techie.net>
---
 libconcord/usblan.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libconcord/usblan.cpp b/libconcord/usblan.cpp
index 6f8f692..2c7b71d 100644
--- a/libconcord/usblan.cpp
+++ b/libconcord/usblan.cpp
@@ -121,7 +121,11 @@ int FindUsbLanRemote(void)
 #endif
 
     if ((err = connect(sock,(struct sockaddr*)&sa,sizeof(sa)))) {
+#ifdef _WIN32
+        if (WSAGetLastError() != WSAEWOULDBLOCK) {
+#else
         if (errno != EINPROGRESS) {
+#endif
             report_net_error("connect()");
             return LC_ERROR_OS_NET;
         }
@@ -135,7 +139,8 @@ int FindUsbLanRemote(void)
     // Change the socket back to blocking which should be fine now that we
     // connected.
 #ifdef _WIN32
-    if(ioctlsocket(sock, FIONBIO, 0) != 0) {
+    non_blocking = 0;
+    if(ioctlsocket(sock, FIONBIO, &non_blocking) != 0) {
         report_net_error("ioctlsocket()");
         return LC_ERROR_OS_NET;
     }
-- 
1.8.3.1


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
_______________________________________________
concordance-devel mailing list
concordance-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/concordance-devel

Reply via email to