diff --git a/src/modbus.c b/src/modbus.c
index db7d033d3f1c0be05cb0f5d08623a369390f0d8e..473a4ee435230a96268eee789ce531ba2c56dbdc 100644 (file)
--- a/src/modbus.c
+++ b/src/modbus.c
#include "collectd.h"
#include "common.h"
#include "collectd.h"
#include "common.h"
-#include "plugin.h"
#include "configfile.h"
#include "configfile.h"
-
-#include <netdb.h>
+#include "plugin.h"
#include <modbus.h>
#include <modbus.h>
+#include <netdb.h>
+#include <sys/socket.h>
#ifndef LIBMODBUS_VERSION_CHECK
/* Assume version 2.0.3 */
#ifndef LIBMODBUS_VERSION_CHECK
/* Assume version 2.0.3 */
}
else if (host->conntype == MBCONN_TCP)
{
}
else if (host->conntype == MBCONN_TCP)
{
- struct sockaddr sockaddr;
- socklen_t saddrlen = sizeof (sockaddr);
-
- status = getpeername (modbus_get_socket (host->connection),
- &sockaddr, &saddrlen);
- if (status != 0)
+ if (getpeername (modbus_get_socket (host->connection),
+ (void *) &(struct sockaddr_storage) {0},
+ &(socklen_t) {sizeof(struct sockaddr_storage)}) != 0)
status = errno;
}
status = errno;
}