Commit 270f02c8dccb663baa0b1d6e518518f4e364d068
1 parent
d2b288be
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.
Showing
1 changed file
with
1 additions
and
1 deletions
src/modbus-tcp.c
| ... | ... | @@ -517,7 +517,7 @@ int modbus_tcp_listen(modbus_t *ctx, int nb_connection) |
| 517 | 517 | addr.sin_port = htons(ctx_tcp->port); |
| 518 | 518 | if (ctx_tcp->ip[0] == '0') { |
| 519 | 519 | /* Listen any addresses */ |
| 520 | - addr.sin_addr.s_addr = INADDR_ANY; | |
| 520 | + addr.sin_addr.s_addr = htonl(INADDR_ANY); | |
| 521 | 521 | } else { |
| 522 | 522 | /* Listen only specified IP address */ |
| 523 | 523 | addr.sin_addr.s_addr = inet_addr(ctx_tcp->ip); | ... | ... |