F
Frank Fredstone
I want to close a socket if the other side is not on the local
machine, how can I do that?
InetAddress.getHostname() is not "localhost" sometimes, if the client
connects to "localhost". For example, sometimes getHostname() returns
"127.0.0.1".
InetAddres.getHostAddress() could be various things...
Would this work reliably:
String remoteHost = remote.getHostName();
InetAddress[] ias = InetAddress.getAllByName(remoteHost);
boolean localhost = false;
for (int i = 0; i < ias.length; ++i) {
InetAddress ia = ias;
if ("localhost".equals(ia.getHostname()) {
localhost = true;
}
}
machine, how can I do that?
InetAddress.getHostname() is not "localhost" sometimes, if the client
connects to "localhost". For example, sometimes getHostname() returns
"127.0.0.1".
InetAddres.getHostAddress() could be various things...
Would this work reliably:
String remoteHost = remote.getHostName();
InetAddress[] ias = InetAddress.getAllByName(remoteHost);
boolean localhost = false;
for (int i = 0; i < ias.length; ++i) {
InetAddress ia = ias;
if ("localhost".equals(ia.getHostname()) {
localhost = true;
}
}