How to listen on multiple IP addresses?

后端 未结 6 1204
别那么骄傲
别那么骄傲 2021-02-15 16:15

If my server has multiple IP addresses assigned to it, and I would like to listen to some (or all) of them, how do I go about doing that?

Do I need to create a new socke

6条回答
  •  忘了有多久
    2021-02-15 17:00

    The MSDN library does seem contradcitory regarding IPAddress.Any. The Bind doc

    http://msdn.microsoft.com/en-us/library/system.net.sockets.socket.bind.aspx

    says that the 'most suitable' address is chosen, but the IPAddress.Any doc

    http://msdn.microsoft.com/en-us/library/system.net.ipaddress.any.aspx

    says that with this constant the socket must listen for activity on all interfaces.

    However, I'm told that it's the IPAddress.Any doc that is correct.

    (adding this as an answer since I don't have enough rep to leave comments).

提交回复
热议问题