Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ AC_CHECK_HEADERS([ \
linux/serial.h \
netdb.h \
netinet/in.h \
netinet/ip.h \
netinet/tcp.h \
sys/ioctl.h \
sys/params.h \
Expand All @@ -104,7 +105,7 @@ AC_CHECK_DECLS([__CYGWIN__])
AC_SEARCH_LIBS(accept, network socket)

# Checks for library functions.
AC_CHECK_FUNCS([accept4 getaddrinfo gettimeofday inet_pton inet_ntop select socket strerror strlcpy])
AC_CHECK_FUNCS([accept4 gai_strerror getaddrinfo gettimeofday inet_pton inet_ntop select socket strerror strlcpy])

# Required for MinGW with GCC v4.8.1 on Win7
AC_DEFINE(WINVER, 0x0501, _)
Expand Down
10 changes: 10 additions & 0 deletions src/modbus-tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
#endif

# include <netinet/in.h>
#ifdef HAVE_NETINET_IP_H
# include <netinet/ip.h>
#endif
# include <netinet/tcp.h>
# include <arpa/inet.h>
# include <netdb.h>
Expand Down Expand Up @@ -401,7 +403,11 @@ static int _modbus_tcp_pi_connect(modbus_t *ctx)
rc = getaddrinfo(ctx_tcp_pi->node, ctx_tcp_pi->service, &ai_hints, &ai_list);
if (rc != 0) {
if (ctx->debug) {
#ifdef HAVE_GAI_STRERROR
fprintf(stderr, "Error returned by getaddrinfo: %s\n", gai_strerror(rc));
#else
fprintf(stderr, "Error returned by getaddrinfo: %d\n", rc);
#endif
}
freeaddrinfo(ai_list);
errno = ECONNREFUSED;
Expand Down Expand Up @@ -627,7 +633,11 @@ int modbus_tcp_pi_listen(modbus_t *ctx, int nb_connection)
rc = getaddrinfo(node, service, &ai_hints, &ai_list);
if (rc != 0) {
if (ctx->debug) {
#ifdef HAVE_GAI_STRERROR
fprintf(stderr, "Error returned by getaddrinfo: %s\n", gai_strerror(rc));
#else
fprintf(stderr, "Error returned by getaddrinfo: %d\n", rc);
#endif
}
freeaddrinfo(ai_list);
errno = ECONNREFUSED;
Expand Down