R
Randolph Carter
Hi everyone, I need help.
I'm doing a client/server application.
The server class extends JFrame and it implements the graphical UI. It
has also a ServerSocket object and when it receives connection
requests from a client, it starts a thread.
The problem is: this class has a button that activates the server
doing this:
ServerSocket s;
private void activate()
{
try{
int port = 1234;
s=new ServerSocket(port);
while(actived)
{
Socket sock = s.accept();
ServerThread sThread=new ServerThread(sock);
sThread.start();
}
}
catch(Exception err) { }
}
but when I push this button and the server starts listening, the UI is
blocked, the button "activate" is still pushed, the server works and
he accepts client connections, but you can't do anything with the
server!
Thank you for your help, and sorry for my English!
Bye
I'm doing a client/server application.
The server class extends JFrame and it implements the graphical UI. It
has also a ServerSocket object and when it receives connection
requests from a client, it starts a thread.
The problem is: this class has a button that activates the server
doing this:
ServerSocket s;
private void activate()
{
try{
int port = 1234;
s=new ServerSocket(port);
while(actived)
{
Socket sock = s.accept();
ServerThread sThread=new ServerThread(sock);
sThread.start();
}
}
catch(Exception err) { }
}
but when I push this button and the server starts listening, the UI is
blocked, the button "activate" is still pushed, the server works and
he accepts client connections, but you can't do anything with the
server!
Thank you for your help, and sorry for my English!
Bye