On 08/26/2008 11:12 AM, Alan Bateman wrote:
David M. Lloyd wrote:
:
I just mean, what would be the benefit of using SocketAddress rather
than using a String or Path directly? You can avoid the difficulties
of extending SocketAddress by simply not using it.
If the protocol or socket address is specified by String then the
implementation would still require to understand the representation so
that it can map to the appropriate socket type and domain. Is the
concern that applications have a dependency on other SocketAddress types?
No, the concern is just that the SocketAddress hierarchy is just kind of
broken (the indicators are the fact that it's an empty abstract class, and
that anywhere it's used, it's immediately casted to a more specific type).
You could change this, but it still seems to me like a kneejerk "make it
look like Unix" kind of thing to do.
Doing this: UnixSocketChannel.open(String) or similar seems more correct to
me. If you go the route of using SocketChannel.open(SocketAddress), for
example, now you've got instanceof checks for each socket type. Does this
not seem like a so-called "code smell" to you?
- DML