IPAddress is a very small class in the
System.Net namespace. It's job is to just represent, well, an IP address. It supports both IPv4 and IPv6 type addresses.
You can make new IP address either by supplying a byte array to the constructor, or using the
IPAddress.TryParse()) method to get one from a string. Exceptions will be thrown if the IP address is malformed (either via strings or byte arrays). When using the constructor, if you supply a byte array of exactly four bytes, it will assume you want an IPv4 address.
Please also note the static fields of
IPAddress are very important when creating servers, all of them are read only.
Any- This tells a
Socketto listen for connections on any network devices. Which may be coming in locally or via a network
Loopback- This tells a
Socketto listen for connections that are only coming in from the local machine (127.0.0.1)
Broadcast- This provides the broadcast IP address to a socket
None- This tells a
Socketnot to listen in for any connections
All of the fields above are for IPv4, but
IPAddress has IPv6 versions of most of these static fields.