Commit 29851c2fa945499ec35b98338173ff37b1f6c5c8

Authored by Stéphane Raimbault
1 parent dcfac5a7

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

Showing 1 changed file with 1 additions and 5 deletions
src/modbus-tcp.c
... ... @@ -266,20 +266,16 @@ static int _modbus_tcp_set_ipv4_options(int s)
266 266 static int _connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen,
267 267 const struct timeval *ro_tv)
268 268 {
269   - int rc;
  269 + int rc = connect(sockfd, addr, addrlen);
270 270  
271 271 #ifdef OS_WIN32
272 272 int wsaError = 0;
273   -
274   - rc = connect(sockfd, addr, addrlen);
275 273 if (rc == -1) {
276 274 wsaError = WSAGetLastError();
277 275 }
278 276  
279 277 if (wsaError == WSAEWOULDBLOCK || wsaError == WSAEINPROGRESS) {
280 278 #else
281   -
282   - rc = connect(sockfd, addr, addrlen);
283 279 if (rc == -1 && errno == EINPROGRESS) {
284 280 #endif
285 281 fd_set wset;
... ...