Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Socket unbind  RSS feed

 
Robert Smith
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello .. i m developinga Server /Client application... Basically clients keep on coonecting server and the hostname of each client is displayed in the list...but what if client connection gets broken in between...? who can i check that the client is no longer present becoz i need to remove the hostname of that client from the displayed list if the client is no longer present.....
Thanx
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mr. Cold,
Welcome to JavaRanch, the absolute best site on the www for Java information. We don't have many rules around here, but we do have one. Please change your display name to a first and last name to comply with the JavaRanch Naming Policy. You can change it here. Thank you for your cooperations.

BTW, It's not often that a world class wrestler of your stature comes to JavaRanch, perhaps you could share some stories with us in our Meaningless Drivel Forum.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For your problem, you can implement a client heart beat which would use a second socket connection. Each client would send a heart beat event at a prescribed interval to the server and if a client missed two (or whatever you decide) heart beats, then the server could remove the client from the list. Alternatively, the server could callback each client at a particular interval to verify that the connection were not stale. Either way, this should run in a separate thread on each client and server.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would Socket.setKeepAlive() help? Under the hood, of course, it does a heartbeat thing as well, but the overhead may be a little bit less.
- Peter
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!