Browse Source

Another quick workaround for deficient OS (closes #63)

It will better to code something such as:
https://github.com/crossroads-io/libxs/blob/master/src/err.cpp

I don't intend to rewrite glib neither :(
Stéphane Raimbault 12 years ago
parent
commit
34ec939a75
1 changed files with 6 additions and 1 deletions
  1. 6 1
      src/modbus-tcp.c

+ 6 - 1
src/modbus-tcp.c

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright © 2001-2011 Stéphane Raimbault <stephane.raimbault@gmail.com>
+ * Copyright © 2001-2013 Stéphane Raimbault <stephane.raimbault@gmail.com>
  *
  *
  * This library is free software; you can redistribute it and/or
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * modify it under the terms of the GNU Lesser General Public
@@ -255,7 +255,12 @@ static int _connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen,
     int rc;
     int rc;
 
 
     rc = connect(sockfd, addr, addrlen);
     rc = connect(sockfd, addr, addrlen);
+
+#ifdef OS_WIN32
+    if (rc == -1 && WSAGetLastError() == WSAEINPROGRESS) {
+#else
     if (rc == -1 && errno == EINPROGRESS) {
     if (rc == -1 && errno == EINPROGRESS) {
+#endif
         fd_set wset;
         fd_set wset;
         int optval;
         int optval;
         socklen_t optlen = sizeof(optval);
         socklen_t optlen = sizeof(optval);