tags:

views:

40

answers:

2

I am from Ethiopia so i am sorry for my English

I was designing a muiltithread server/client application and the server has its own user interface that keep the list of all connected client the problem is

ss = new ServerSocket( port );

while (true) {
// Grab the next incoming connection

 s = ss.accept();

ss.accept(); block the entire process and i am not able to access other functionalities of the server. the user interface of the server completly freez even though the server is accepting new clients and the client side is working perfectly.

so what shall i do to make the server accept new connection while processing other things

A: 

you should spawn thread and call accept there

Andrey
The question asker should study Multithreading first, I believe.
tafa
+1  A: 

There are two (popular) ways of doing this:

  1. A main thread containing a blocking loop waiting for clients. This main thread spawns a new Thread when a client is accepted.

  2. Java New Input/Output. Everything is handled in the main thread. See http://rox-xmlrpc.sourceforge.net/niotut/index.html

Also: you point out your server application has a User Interface. A User Interface should be running in a different thread (the Event Dispatcher Thread, EDT) than the server.

Pindatjuh