Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Catch a Disconnect event in Client-Server Socket enviroment

Catch a Disconnect event in Client-Server Socket enviroment

Scheduled Pinned Locked Moved C#
sysadminhelploungeworkspace
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Gian
    wrote on last edited by
    #1

    Hello, i've setup a simple chat program using the Socket class with Async send and receive. All work good but i cant find an event that from the Server application warn it that a socket connection with a client is disconnected from the client itself. I can send a "disconnection" message from the client before closing the application but it doesnt work if for some kind of problem the program terminates (networking problems, crash of the computer, etc). Thanks in advance for any ideas Gian

    D 1 Reply Last reply
    0
    • G Gian

      Hello, i've setup a simple chat program using the Socket class with Async send and receive. All work good but i cant find an event that from the Server application warn it that a socket connection with a client is disconnected from the client itself. I can send a "disconnection" message from the client before closing the application but it doesnt work if for some kind of problem the program terminates (networking problems, crash of the computer, etc). Thanks in advance for any ideas Gian

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      There is no event that's fired when the client crashes. There is no way for the server to know that the client crashed unless it attempts to send something to the client. Only then will the server be able to detect the send failure and raise it's own event to the remaining clients. A way around this might be to implement a "heartbeat". Either the server would send out a "ping" to all of the clients requiring the clients to send the data in the ping back to the server or the clients would have to send "heartbeat" packets to the server. Either method would have to be on a set time, say once every 10 seconds. If the heartbeat or ping is no longer detected after a specified timeout value, say 30 seconds, then the server can assume that the client is no longer functional and raise its own event that notifies the remaining clients. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups