I need to determine if an InetSocketAddress
is IPv6 or IPv4 efficiently. The only two ways I can see of doing this are either using the instanceof
operator, or checking the length of getAddress()
(which should return a byte[]
). Both of these are less than ideal (instanceof
is slow, and getAddress
would have to make a copy of the array).
Is there a better alternative?