client server connection only allows 1 client
I am learning how to do the client server coding in java, and i have created what i thought was a multithreaded server. my understanding of a multithreaded server was one that could accept multiple clients. i have posted my code below in hopes someone could tell me why it will not allow multiple clients. right now i have the client pointing to the ip address of my computer(not the network address ie: 192.168.....) i start the server and then run a client on one computer on the network, and it will work fine, when i then run another client on the other computer it will not even display the gui until i close the 1st client that was opened. my server is connected to a class called conversation that handles all sql commands on a derby database. my server code is posted below.
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.WindowConstants;
publicclass Serverextends Thread{
publicfinalstaticint defaultPort = 5555;
int port;
ServerSocket listenSocket;
Socket clientSocket;
JFrame frame =new JFrame();
publicstaticvoid main(String args[]){
int port = 0;
if (args.length ==1){
try{
port=Integer.parseInt(args[0]);
}catch(NumberFormatException e){
port=0;
}
}
new Server(port);
//new guiServer();
}
public Server(int aport){
if(aport==0)
aport = defaultPort;
this.port = aport;
try{
listenSocket =new ServerSocket(port);
}catch(IOException e){
fail(e,"Exception creating server socket");
}
System.out.println("Server listening on port " + port);
this.start();
}//end Server(int aport)
publicvoid fail(Exception e, String msg){
JOptionPane.showMessageDialog(frame,msg +": " + e,"Warning",JOptionPane.WARNING_MESSAGE);
System.exit(1);
}// end fail
publicvoid run(){
frame =new JFrame("MMSI SERVER");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
int width = 50;
int height = 50;
frame.setSize(width, height);
frame.setVisible(true);
try{
while(true){
clientSocket = listenSocket.accept();
conversation conv =new conversation(clientSocket);
}
}catch(IOException e){
fail(e,"Exception listening for connections");
}
}// end run
}//end Server
class conversationextends Thread{
..................... on to db connection and sql commands.

