problem with InetAddress.getaddress

  • Thread starter nooneinparticular314159
  • Start date
N

nooneinparticular314159

I'm trying the following:

InetAddress ServerAddress = null;
ServerIPAddressBytes =
IPMapper.GetIPAddressAsByteArray(ServerToConnectTo);
try{
ServerAddress.getByAddress(ServerIPAddressBytes);
} catch (UnknownHostException Exception) {
System.out.println("Client: UnknownHostException when
trying to create an InetAddress");
System.exit(-1);
}

where my GetIPAddressAsByteArray method will return a 4 byte array with
an IP address in it. Running this through my debugger, ServerAddress
apparently never changes from Null. It should be returning an
InetAddress object, but instead ServerAddress remains null. Any idea
why this is happening, and not returning an InetAddress?

Thanks!
 
E

EJP

InetAddress ServerAddress = null;
ServerIPAddressBytes =
IPMapper.GetIPAddressAsByteArray(ServerToConnectTo);
try{
ServerAddress.getByAddress(ServerIPAddressBytes);
} catch (UnknownHostException Exception) {
System.out.println("Client: UnknownHostException when
trying to create an InetAddress");
System.exit(-1);
}

where my GetIPAddressAsByteArray method will return a 4 byte array with
an IP address in it. Running this through my debugger, ServerAddress
apparently never changes from Null.
It should be returning an
InetAddress object, but instead ServerAddress remains null. Any idea
why this is happening, and not returning an InetAddress?

Why should it? You're setting it to null, and you never change it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,609
Members
45,253
Latest member
BlytheFant

Latest Threads

Top