开发者

Socket.bind to all ips - An invalid argument was supplied

开发者 https://www.devze.com 2023-04-07 10:11 出处:网络
I want to bind the socket t开发者_如何学Goo all the IP addresses available on the machine using:

I want to bind the socket t开发者_如何学Goo all the IP addresses available on the machine using:

  mainSocket.Bind(new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0)); //or IPAddress.Any

but I get an An invalid argument was supplied on

 mainSocket.IOControl(IOControlCode.ReceiveAll, byTrue, byOut);

Instead, when I specify the IP, it works just fine.

Socket.bind to all ips - An invalid argument was supplied

Ok maybe that's impossible to achieve. But how about detecting which internet interface is being used to connect to internet and getting it's ip? (assuming user is behind NAT / router)


I think it's not possible. Operation with sockets has limitations according to this document TCP/IP Raw Sockets

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号