- 1,229
- 0
How do I make a SocketAddress that I can pass to a Socket so that I can connect to a computer whose IP address I have as a string? I think that want I want is an Inet4Address but Inet4Address has no constructor. SocketAddress says it is meant to be "subclassed" by a protocol-specific address type, but I don't know what they mean. Is there a factory class that will do this for me?
Edit: I made my own method to parse it into a byte[] but now it won't accept an InetAddress as a SocketAddress. An InetAddress is a SocketAddress though. And it won't let me cast it. What's the deal?
Edit: Never mind, an InetSocketAddress is a SocketAddress, an InetAddress isn't. I still would like to know if there is a built-in way to make an InetAddress from a string though. In Inet4Address it seems to suggest that there is, since it specifies the format of such a string.
Edit: I made my own method to parse it into a byte[] but now it won't accept an InetAddress as a SocketAddress. An InetAddress is a SocketAddress though. And it won't let me cast it. What's the deal?
Edit: Never mind, an InetSocketAddress is a SocketAddress, an InetAddress isn't. I still would like to know if there is a built-in way to make an InetAddress from a string though. In Inet4Address it seems to suggest that there is, since it specifies the format of such a string.
Last edited: