Re: Create InetAddress from a String.



On Fri, 2005-04-29 at 17:53 +0000, jseidelREMOVECAPS@xxxxxxxxxxxx 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. I need to create
> an InetAddress from it. How do I do that?
>
> Jerry

For example:

import java.net.InetAddress;
import java.net.UnknownHostException;

try {
InetAddress in = InetAddress.getByName("www.somewhere.com");
} catch (UnknownHostException e) {
// .. whatever
}

Ross

--
[Ross A. Bamford] [ross AT the.website.domain]
Roscopeco Open Tech ++ Open Source + Java + Apache + CMF
http://www.roscopec0.f9.co.uk/ + info@xxxxxxxxxxxxxxxxxx


.



Relevant Pages

  • Create InetAddress from a String.
    ... I need to create a socket connection to a site. ... socket sock = new socket(name, port); ... This wont work because the name isn't an ip address. ...
    (comp.lang.java.programmer)
  • Re: Create InetAddress from a String.
    ... > socket sock = new socket(name, port); ... > This wont work because the name isn't an ip address. ...
    (comp.lang.java.programmer)
  • How do you create an InetAddress from a String.
    ... I need to create a socket connection to a site. ... socket sock = new socket(name, port); ... This wont work because the name isn't an ip address. ...
    (comp.lang.java)