how to shut down the multithreaded socket server
Hi friends Iam developed an Multithreaded Socket server application,in that seperate threads are created for each accept connection of client socket.Each Threads performing the processing of data coming from the client and send back the processed data to the client.In that application i am having idea to put button for shut down the server.If that button is pressed my entire application going to shut down.How to achieve this?can anyone tell me the way... Iam implemented by this by closing the server socket,in this case if the client socket processing any data means it lost.so i need to close the client socket after sending messaging to the client.How to do this task?anyone know this way...?
[706 byte] By [
83Krisha] at [2007-11-27 8:42:22]

> Iam implemented by this by closing the server
> socket,in this case if the client socket processing
> any data means it lost.
No it doesn't. The accepted client socket is independent of the server socket. Any data loss is due to the code that handles that connection, nothing to do with the server socket.
> so i need to close the client
> socket after sending messaging to the client.How to
> do this task?anyone know this way...?
Close the output stream of the socket.
ejpa at 2007-7-12 20:41:40 >

hi iam created the server socket.... that server socket is going to accept the n number of client socket in the infinite loop... At present server socket dont have any connection to the client socket,if i close the server socket it results socketexception arises....coz still my server socket is accept on the client socket... how to avoid this exception....?can u tell me the suggestion...
> if i close the server socket it results
> socketexception arises ....coz still my server socket
> is accept on the client socket...
I can barely understand all this. Do you mean that ServerSocket.accept() is throwing an IOException after you close the server socket? If so, what did you expect? That's what's supposed to happen.
> how to avoid this exception....?
You can't avoid it. You can catch it and deal with it.
In this case, any IOException from ServerSocket.accept() just means close the server socket and stop the accept loop.
Similarly any IOException on any socket I/O operation means the socket is kaput - all you can do is log it and close the connection.
ejpa at 2007-7-12 20:41:40 >
