try {
ServerSocket ss = new ServerSocket(port);
while (true) {
try {
Socket s = ss.accept();
Writer out = new OutputStreamWriter(s.getOutputStream());
out = new BufferedWriter(out);
out.write("Hello " + s.getInetAddress() + " on port "
+ s.getPort() + "\r\n");
out.write("This is " + s.getLocalAddress() + " on port "
+ s.getLocalPort() + "\r\n");
out.flush();
s.close();
}
catch (IOException e) {}
}
}
catch (IOException e) { System.err.println(e); }