4

I'm creating an socket that needs to listen on all network interfaces on a specific port.

I create it using INADDR_ANY, so the socket listen correctly on all local IP addresses.

My question is: what happens if a new interface goes up? Does the socket automatically listen to the new interface, or do I have to rebind it?

Example: My socket is already listening, and I create a wifi ad-hoc connection. Do I need to detect that a new interface is available (the ad-hoc one), and rebind the socket?

(I'm using C++ on windows right now, but the code will have to be ported to MacOS)

1 Answer 1

3

INADDR_ANY really means any interface, not 'all' interfaces. As such it doesn't matter whether the interface even existed when the socket was bound.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.