470,815 Members | 1,094 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,815 developers. It's quick & easy.

How do you create an InetAddress from a String.


I need to create a socket connection to a site.
String name = "elektra.usm.com"
socket sock = new socket( name, port );

This wont work because the name isn't an ip address. I need to create
an InetAddress from it. How do I do that?

Jerry
Jul 18 '05 #1
1 4052
On Fri, 29 Apr 2005 17:51:03 GMT, js***************@maine.rr.com wrote:
I need to create a socket connection to a site.

String name = "elektra.usm.com"
socket sock = new socket( name, port );

This wont work because the name isn't an ip address.
Yes it will, because the Socket constructor will gladly accept either
a hostname or an InetAddress.

I need to create an InetAddress from it. How do I do that?


You don't need to.

However InetAddress has a factory method that takes a hostname and
returns an InetAddress instance.

/gordon

--
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Michael Sperlle | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.