Can we run multiple clients & 1 server on a single machine? Let's say I have a server class (thread for multiple connections) and a client class as well. I want to run at least 2 clients at the same time but they have separate chat window(Server to client but not Group chat). Is it Possible? I have this code
public void server(){
ss = new ServerSocket(port);
chatprocess cp = new chatprocess(socket);// accept connection inside and input/output as well
}
public client(){
socket = new socket("localhost",port);
clientprocess(); //i/o inside
}
Yes.
In order to do that you must create a thread assigned for each client. There are a lot of examples here in SO.