How could I get a broadcast address on given port?
How can I get a broadcast address for a g开发者_开发百科iven port in C#?
Is using something in
NetworkInterface.GetAllNetworkInterfaces()
the right way?
Thank you
Clarification: I'd like to get an array of all broadcast addresses. Then I'd add a given port and return IPEndPoint[].
I did it by getting IP address, subnet mask and then doing IP OR ~SUBNET on each byte.
broadcast[i] = (byte)(ip[i] | ~sub[i]);
精彩评论