Socket.bind to all ips - An invalid argument was supplied
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.
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
精彩评论