The tutorial you mentioned is very simple. You cannot write any reasonable server without using threads. To have two server sockets, you must create a new thread for each port, for example this (pseudo-code):
new Thread() { public void run() { ServerSocket server = new ServerSocket(6788); while(true) { Socket client1 = server.accept();
and (pay attention to another port):
new Thread() { public void run() { ServerSocket server = new ServerSocket(6789); while(true) { Socket client1 = server.accept();
Having sockets client1 and client2 , you can process them separately. In addition, client connection processing must be done in a different thread so that you can serve multiple clients. Of course, this code introduces a lot of duplication, but consider this a starting point.
To wrap everything - if your goal is to implement HTTP GET and PUT, use a servlet and avoid all this fuss.
source share