for (InetAddress address : InetAddress.getAllByName(localhost.getHostAddress())) {
System.out.println(" " + address);
}
InetAddress address = InetAddress.getByName(localhost.getHostAddress());
System.out.println("byName:" + address);
ServerSocket serverSocket;
try {
serverSocket = new ServerSocket(0);
} catch (Exception e) {
e.printStackTrace();
serverSocket = new ServerSocket(0);
}
System.out.println(serverSocket);
int port = serverSocket.getLocalPort();
final ServerSocket accept = serverSocket;
Thread thread = new Thread() {
public void run() {
try {
System.out.println("server accepting");
Socket s = accept.accept();
Thread.sleep(100);
System.out.println("server accepted:" + s);
System.out.println("server read:" + s.getInputStream().read());
Thread.sleep(200);
s.getOutputStream().write(234);