Selaa lähdekoodia

INADDR_* macros are defined in host byte order

From Michael Heimpold:
Just a nitpick: the INADDR_* macros are defined in host byte order,
compare INADDR_LOOPBACK. So it would be reasonable to wrap this with
htonl(INADDR_ANY). However, every experienced socket programmer should
know that INADDR_ANY equals 0.0.0.0, passing it through htonl does not
have any effect.
Stéphane Raimbault 11 vuotta sitten
vanhempi
commit
270f02c8dc
1 muutettua tiedostoa jossa 1 lisäystä ja 1 poistoa
  1. 1 1
      src/modbus-tcp.c

+ 1 - 1
src/modbus-tcp.c

@@ -517,7 +517,7 @@ int modbus_tcp_listen(modbus_t *ctx, int nb_connection)
     addr.sin_port = htons(ctx_tcp->port);
     if (ctx_tcp->ip[0] == '0') {
         /* Listen any addresses */
-        addr.sin_addr.s_addr = INADDR_ANY;
+        addr.sin_addr.s_addr = htonl(INADDR_ANY);
     } else {
         /* Listen only specified IP address */
         addr.sin_addr.s_addr = inet_addr(ctx_tcp->ip);