• Post Reply Bookmark Topic Watch Topic
  • New Topic

Related to ServerSocket

 
Sachindra Pratap
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working on Java Desktop application with client server architecture.
The prob. is , suppose there are two machines, on both my swing desktop application is running. And on one ServerSocket is running ,and on other
clientSocket is running.
And in my application ServerSocket only closes when there is proper logout(means in my gui i have logout button) on clicking logut button,
ServerSocket (object) gets close.So that, when we login next time ,
port should be available for ServerSocket to listen.

On the other machine i.e client , on particular events packets are send to ServerSocket.where serversocket listen to request and do the job.

But the problem is that suppose improper logout occur at serversocket end,
the port for serverSocket does not get releases ,meanwhile if clientSocket
send request to serverSocket ,connection refused exception is thrown.

Since jvm keeps serverSocket running on server machine .
So any body can suggest how to close the serverSocket automatically.

a prompt reply is awaited.

Sachindra
 
Joe Ess
Bartender
Posts: 9361
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I anticipate that you have a single threaded application, where the same thread that listens for connections also services the client's requests.
You'll need to split that work up into at least separate threads, one to listen to connections and any number of threads to service clients. This way, one client malfunctioning will not stop your server from accepting and servicing other clients.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!