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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Detecting Loss of Client With CSockets

Detecting Loss of Client With CSockets

Scheduled Pinned Locked Moved C / C++ / MFC
sysadminquestion
4 Posts 3 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.
  • S Offline
    S Offline
    softwaremonkey
    wrote on last edited by
    #1

    Is there an easy way for a server, implemented with CSockets, to know when one or more clients have disconnected antisocially e.g. network unplugged, powered off etc? I want to prevent a build up of 'obsolete' CSockets in my servers client list. TIA ;)

    N 1 Reply Last reply
    0
    • S softwaremonkey

      Is there an easy way for a server, implemented with CSockets, to know when one or more clients have disconnected antisocially e.g. network unplugged, powered off etc? I want to prevent a build up of 'obsolete' CSockets in my servers client list. TIA ;)

      N Offline
      N Offline
      Neil Van Eps
      wrote on last edited by
      #2

      Use CAsyncSocket instead of CSocket and handler OnClose() event.

      S J 2 Replies Last reply
      0
      • N Neil Van Eps

        Use CAsyncSocket instead of CSocket and handler OnClose() event.

        S Offline
        S Offline
        softwaremonkey
        wrote on last edited by
        #3

        Great thanks! Can't I can still use CSocket as this is subclassed from CAsyncSocket? Thanks again! Tony :cool:

        1 Reply Last reply
        0
        • N Neil Van Eps

          Use CAsyncSocket instead of CSocket and handler OnClose() event.

          J Offline
          J Offline
          JonEngle
          wrote on last edited by
          #4

          He's right, but it doesn't work in all cases: client --- router ---- router -- server ^ break connection here If the network connection is broken between the client and server here, neither receives an error until they try to send data. Depending on how things are setup in your app, you might want to consider doing a ping message.

          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