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. How to validate a socket descripter

How to validate a socket descripter

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
5 Posts 4 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.
  • V Offline
    V Offline
    vikramlinux
    wrote on last edited by
    #1

    Hi Guys, Is there any way to validate a socket descriptor before doing any IO on it? ~ Vikram S

    L 1 Reply Last reply
    0
    • V vikramlinux

      Hi Guys, Is there any way to validate a socket descriptor before doing any IO on it? ~ Vikram S

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      What do you mean by validate, against what criteria?

      Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

      V 1 Reply Last reply
      0
      • L Lost User

        What do you mean by validate, against what criteria?

        Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

        V Offline
        V Offline
        vikramlinux
        wrote on last edited by
        #3

        For example I am holding an client socket connected with some server. The server goes down or network goes down. Before doing any action I want to know is the socket in good state.

        C J 2 Replies Last reply
        0
        • V vikramlinux

          For example I am holding an client socket connected with some server. The server goes down or network goes down. Before doing any action I want to know is the socket in good state.

          C Offline
          C Offline
          Chuck OToole
          wrote on last edited by
          #4

          Ah, the age old problem. Look, when two asynchronous processes are communicating things can go wrong at any moment. Even if there was a great way for you to check to see if the socket is in a good state, 1/2 microsecond later it could go bad so you'd still have to handle the "bad state" case when you access the socket connection. Just because it was in a good state an instant ago doesn't mean it still is, that's the nature of asynchronous communications and networks. The falicy is expecting orderly things to happen in a disorderly world. Better to concentrate your efforts in dealing with the "error conditions", trying to communicate with the socket and discovering it's in a "bad state" by handling the failure returns, timeouts, etc. Handle the "disorderly shutdown" cases and you'll discover that the "orderly shutdown" cases fall out nicely.

          1 Reply Last reply
          0
          • V vikramlinux

            For example I am holding an client socket connected with some server. The server goes down or network goes down. Before doing any action I want to know is the socket in good state.

            J Offline
            J Offline
            jschell
            wrote on last edited by
            #5

            Besides the other reply note as well that there is no way to insure that a socket is working without sending something (reading will not work.)

            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