From 29851c2fa945499ec35b98338173ff37b1f6c5c8 Mon Sep 17 00:00:00 2001 From: Stéphane Raimbault Date: Thu, 30 Jan 2014 00:52:40 +0100 Subject: [PATCH] Avoid twice connect() in source code (closes #194) --- src/modbus-tcp.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/modbus-tcp.c b/src/modbus-tcp.c index ebfe2df..96dda63 100644 --- a/src/modbus-tcp.c +++ b/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; -- libgit2 0.21.4