I am building a simple Java server which simultaneously listens for client request on two ports simultaneously using two ServerSocket instances. Here is the code for Server:
PrintWriter is buffered by defaut. Add a writer.flush() (or even better a close() since you're not using the stream anymore) after writer.println().
writer.flush()
close()
writer.println()