• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Related to ServerSocket

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
There are 10 kinds of people in this world. Those that understand binary get this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic