//
// Some things moved here for easier compilation.
//
helper
import java.io.*;
import java.net.*;
import naccio.library.Check;
public class SocketHelp {
public static String getLocalHostName () {
try {
String res;
if (NCheck.isChecking ()) {
NCheck.noChecking ();
res = InetAddress.getLocalHost().getHostName();
NCheck.resumeChecking ();
} else {
res = InetAddress.getLocalHost().getHostName();
}
return res;
} catch (UnknownHostException e) {
NCheck.violation ("Unable to determine localhost address.");
return null;
}
}
public static InetAddress getLocalAddress () {
try {
InetAddress res;
if (NCheck.isChecking ()) {
NCheck.noChecking ();
res = InetAddress.getLocalHost();
NCheck.resumeChecking ();
} else {
res = InetAddress.getLocalHost();
}
return res;
} catch (UnknownHostException e) {
NCheck.violation ("Unable to determine localhost address.");
return null;
}
}
public static String absoluteName (String hostname) {
String res;
try {
if (NCheck.isChecking ()) {
NCheck.noChecking ();
res = java.net.InetAddress.getByName(hostname).getHostName();
NCheck.resumeChecking ();
} else {
res = java.net.InetAddress.getByName(hostname).getHostName();
}
return res;
} catch (java.net.UnknownHostException e) {
NCheck.debugMessage
("Unable to determine absolute hostname for \"" +
hostname + "\".");
return (hostname);
}
}
}
Naccio Home Page
University of Virginia, Computer Science