Explorar o código

Avoid twice connect() in source code (closes #194)

Stéphane Raimbault %!s(int64=11) %!d(string=hai) anos
pai
achega
29851c2fa9
Modificáronse 1 ficheiros con 1 adicións e 5 borrados
  1. 1 5
      src/modbus-tcp.c

+ 1 - 5
src/modbus-tcp.c

@@ -266,20 +266,16 @@ static int _modbus_tcp_set_ipv4_options(int s)
 static int _connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen,
                     const struct timeval *ro_tv)
 {
-    int rc;
+    int rc = connect(sockfd, addr, addrlen);
 
 #ifdef OS_WIN32
     int wsaError = 0;
-
-    rc = connect(sockfd, addr, addrlen);
     if (rc == -1) {
         wsaError = WSAGetLastError();
     }
 
     if (wsaError == WSAEWOULDBLOCK || wsaError == WSAEINPROGRESS) {
 #else
-
-    rc = connect(sockfd, addr, addrlen);
     if (rc == -1 && errno == EINPROGRESS) {
 #endif
         fd_set wset;