SCJP, SCJD
I added a method to my controller to test the connection (the IP address has already been validated), and it will display a message dialog if it gets a RemoteException.
Roel De Nijs wrote:I used following code to try to get the registry
Cheers, Roberto Perillo
SCJP, SCWCD, SCJD, SCBCD
Pedro Kowalski wrote:Norbert, if you want to validate your IP address, didn't you consider using
InetAddress.getByName(-) method? (http://download.oracle.com/javase/6/docs/api/)
It will check if your IP format is appropriate, just as the javadoc states.
Cheers!
Determines the IP address of a host, given the host's name.
Parameters:
host - the specified host, or null.
Returns:
an IP address for the given host name.
Determines the IP address of a host, given the host's name.
The host name can either be a machine name, such as "java.sun.com", or a textual representation of its IP address. If a literal IP address is supplied, only the validity of the address format is checked.
For host specified in literal IPv6 address, either the form defined in RFC 2732 or the literal IPv6 address format defined in RFC 2373 is accepted. IPv6 scoped addresses are also supported. See here for a description of IPv6 scoped addresses.
Norbert Lebenthal wrote:wasn't it said earlier in the topic that actually InetAddress.getByAddress(byte[] addr) doesn't check for existence of the target ? If so, then InetAddress.getByName is sensibly the same.
Roel De Nijs wrote:Ok, I just read the short description of the method and ignored the complete description, my mistake
![]()
Roel De Nijs wrote:
Norbert Lebenthal wrote:wasn't it said earlier in the topic that actually InetAddress.getByAddress(byte[] addr) doesn't check for existence of the target ? If so, then InetAddress.getByName is sensibly the same.
Correct, I tested it here. Maybe you can run the same tests as I did in that reply and post your results. If both methods would give the same results, using InetAddress.getByName is simpler (and thus better)
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |