net: Bind IP and get IP via DHCP: is the altered behavior intended or not? #71600
-
Hey net experts! I was about to create an issue with a merged pull request, but I solved it in the application, but I am still not sure: Is the altered behavior intended or not?The issue would have looked like this: Title: Describe the bug
The symptoms:
To Reproduce Setup something like this:
code:
Give the client another IP address with DHCP server. Try to exchange messages with e.g. echo server. Responses do not trigger the associated callbacks in the client, because the incoming response is not matched with the connection. Expected behavior Impact Logs and console output Environment (please complete the following information):
Additional context |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
This is the culprit, when binding, you need to decide whether to bind to any address or to one specific address. If the IP address changes, and you are binding to specific address, then the packets cannot be delivered to proper socket. |
Beta Was this translation helpful? Give feedback.
This is the culprit, when binding, you need to decide whether to bind to any address or to one specific address. If the IP address changes, and you are binding to specific address, then the packets cannot be delivered to proper socket.
So depending on use case, you should usually always bind using any address (INADDR_ANY) instead of a specific IP address.