You have to change your port for the second ServerSocket
instance, since only one ServerSocket
can be bound to the same port at the same time.
I suggest to improve your server
class with something like this:
public class server {
private static int port = 5000;
public server(int yourParameter) {
/*...*/
service = new ServerSocket(port++);
/*...*/
}
}
This code will allow your servers to be bound to an always increasing port, starting from 5000.