try {
ServerSocket ss = new ServerSocket(2345);
Socket s = ss.accept();
Writer out = new BufferedWriter(
new OutputStreamWriter(s.getOutputStream(), "UTF-8")
);
out.write("Hello There!\r\n");
out.write("Goodbye now.\r\n");
out.flush();
s.close();
}
catch (IOException ex) {
System.err.println(ex);
}