try {
ServerSocket serverSock = new ServerSocket(4200);
while(true) {
Socket sock = serverSock.accept();
PrintWriter writer = new PrintWriter(sock.getOutputStream());
String advice = getAdvice();
writer.println(advice);
writer.close(); // must have THIS or flush() or it never writes...
System.out.println(advice);
}
} catch(IOException ex) {
ex.printStackTrace();
}