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. detect if tcp connection dropped/aborted

detect if tcp connection dropped/aborted

Scheduled Pinned Locked Moved C#
sysadmincsharphelpquestion
4 Posts 4 Posters 1 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.
  • B Offline
    B Offline
    batmanAgen
    wrote on last edited by
    #1

    hi guys, im developing a client/server app and i need to continuously check the connection between my server and its clients... how can i do that in c#.. how will i know if a connection is dropped.. or if my network cable is disconnected from the lancard.. im new in network programming.. i greatly appreciate any help and suggestions.. tnx guys..

    D L M 3 Replies Last reply
    0
    • B batmanAgen

      hi guys, im developing a client/server app and i need to continuously check the connection between my server and its clients... how can i do that in c#.. how will i know if a connection is dropped.. or if my network cable is disconnected from the lancard.. im new in network programming.. i greatly appreciate any help and suggestions.. tnx guys..

      D Offline
      D Offline
      Dario Solera
      wrote on last edited by
      #2

      The Receive/Send or BeginReceive/BeginSend methods will return 0 bytes received/sent when the connection is lost or closed by the other host. ___________________________________ Tozzi is right: Gaia is getting rid of us. My Blog [ITA]

      1 Reply Last reply
      0
      • B batmanAgen

        hi guys, im developing a client/server app and i need to continuously check the connection between my server and its clients... how can i do that in c#.. how will i know if a connection is dropped.. or if my network cable is disconnected from the lancard.. im new in network programming.. i greatly appreciate any help and suggestions.. tnx guys..

        L Offline
        L Offline
        leppie
        wrote on last edited by
        #3

        If the connection drops or gets severed, or when the timeout expires an exception will be thrown. I tend to send a 'blank' packet every 30-60 seconds, to force 'detection' of the network state. If its idle, it cant detect an error state. HTH :)

        xacc.ide-0.1.1.11 - now with Settings & AutoComplete(kinda)

        1 Reply Last reply
        0
        • B batmanAgen

          hi guys, im developing a client/server app and i need to continuously check the connection between my server and its clients... how can i do that in c#.. how will i know if a connection is dropped.. or if my network cable is disconnected from the lancard.. im new in network programming.. i greatly appreciate any help and suggestions.. tnx guys..

          M Offline
          M Offline
          mcljava
          wrote on last edited by
          #4

          One final note, since you can detect socket end of file (0 return of recv) you still need to plan for how to convey that event to your mainline code if it is not the same line of executing code. Typically a ManualResetEvent or Semaphore works fine for this. Particulary if we are talking about a multi-threaded model. Mike Luster

          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