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. How to Ping?

How to Ping?

Scheduled Pinned Locked Moved C#
tutorialquestion
8 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.
  • A Offline
    A Offline
    Alper Camel
    wrote on last edited by
    #1

    My user profile is not Admin. I wrote a code that sends ping, it works when I logon with admin password, but doesn't work when I logon with my user (that is not admin). Thanks..

    C 1 Reply Last reply
    0
    • A Alper Camel

      My user profile is not Admin. I wrote a code that sends ping, it works when I logon with admin password, but doesn't work when I logon with my user (that is not admin). Thanks..

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      To write a ping program in C# requires raw sockets. Raw sockets are only permitted in .NET when the user is logged on with admin privileges.


      My: Blog | Photos | Next SQL Presentation WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More

      A 1 Reply Last reply
      0
      • C Colin Angus Mackay

        To write a ping program in C# requires raw sockets. Raw sockets are only permitted in .NET when the user is logged on with admin privileges.


        My: Blog | Photos | Next SQL Presentation WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More

        A Offline
        A Offline
        Alper Camel
        wrote on last edited by
        #3

        Thank you for your reply! Ok. I got it. I need admin account. Actually My problem is ; I wrote a small server (listens tcp port), when a client's cable unplugged, I want my server detect this, and says this client is disconnected, Do you know how can I do it? thank you very much...

        D 1 Reply Last reply
        0
        • A Alper Camel

          Thank you for your reply! Ok. I got it. I need admin account. Actually My problem is ; I wrote a small server (listens tcp port), when a client's cable unplugged, I want my server detect this, and says this client is disconnected, Do you know how can I do it? thank you very much...

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

          The server cannot detect this at all. As I put in your other post, PING'ing the client is not a reliable method considering the client might be behind a firewall or NAT that won't let ICMP traffic through it. The only thing you can do is build in a "keep alive" where the client must send these "keep alive" requests to the server every so often. If the server stops receiving these requests from the client within a specified time period, it can assume that the client is no longer connected. I don't know how much traffic or how many clients you're expecting, but this has scalability limitations. If you get enough clients connected, you could conceivably have 80%, or more, of the traffic going to the server just "keep alive"'s, resulting in very slow performance. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

          A 1 Reply Last reply
          0
          • D Dave Kreskowiak

            The server cannot detect this at all. As I put in your other post, PING'ing the client is not a reliable method considering the client might be behind a firewall or NAT that won't let ICMP traffic through it. The only thing you can do is build in a "keep alive" where the client must send these "keep alive" requests to the server every so often. If the server stops receiving these requests from the client within a specified time period, it can assume that the client is no longer connected. I don't know how much traffic or how many clients you're expecting, but this has scalability limitations. If you get enough clients connected, you could conceivably have 80%, or more, of the traffic going to the server just "keep alive"'s, resulting in very slow performance. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

            A Offline
            A Offline
            Anonymous
            wrote on last edited by
            #5

            That's Right. but my problem is that my clients may anyone. I mean. any client who knows my server IP and Port Number can connect to my server. that is clients cannot send me message that they are online or something.. because they don't know the way I search them... They can only send me string messages and my server display it on the received screen.. (of sure incoming messages are token as bytes no problem at this fact at all).. As a result, server has to detect which clients are online or not! by a way ping or something.. By this way , I know that all the work done by server and server has much work to do.. But I have to... Thank you very much for reply.. Greetings.... Alper. Software Developer.

            D 1 Reply Last reply
            0
            • A Anonymous

              That's Right. but my problem is that my clients may anyone. I mean. any client who knows my server IP and Port Number can connect to my server. that is clients cannot send me message that they are online or something.. because they don't know the way I search them... They can only send me string messages and my server display it on the received screen.. (of sure incoming messages are token as bytes no problem at this fact at all).. As a result, server has to detect which clients are online or not! by a way ping or something.. By this way , I know that all the work done by server and server has much work to do.. But I have to... Thank you very much for reply.. Greetings.... Alper. Software Developer.

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

              Your client may be anyone, anywhere on the planet? Since you're trying to determine if the client disconnects unexpectedly, I'm assuming that you have to keep state information for the duration of the client session. Is this correct? Are you writing a client piece to this also? If so, then you could include code that would send a "keep alive" request back to the server so the server knows it's still connected. After a certain timeout, if no "keep alive" request has been received by the server, you can assume the client either lost communication or terminated the client for some reason. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

              A 1 Reply Last reply
              0
              • D Dave Kreskowiak

                Your client may be anyone, anywhere on the planet? Since you're trying to determine if the client disconnects unexpectedly, I'm assuming that you have to keep state information for the duration of the client session. Is this correct? Are you writing a client piece to this also? If so, then you could include code that would send a "keep alive" request back to the server so the server knows it's still connected. After a certain timeout, if no "keep alive" request has been received by the server, you can assume the client either lost communication or terminated the client for some reason. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                A Offline
                A Offline
                Alper Camel
                wrote on last edited by
                #7

                Unfortunately I'm writing only the Server Part, and the clients are electronic cards that has the client code in their EP-ROM and flash memory. If their battery gets low or power-off my or their network cable unplugged, my server has to detect it. Because the memory is very important for the EP-ROM based electronic cards client. Any Keep-Alive Send code couldnt be added into the clients. Again Thank you very much...

                D 1 Reply Last reply
                0
                • A Alper Camel

                  Unfortunately I'm writing only the Server Part, and the clients are electronic cards that has the client code in their EP-ROM and flash memory. If their battery gets low or power-off my or their network cable unplugged, my server has to detect it. Because the memory is very important for the EP-ROM based electronic cards client. Any Keep-Alive Send code couldnt be added into the clients. Again Thank you very much...

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

                  You could have put that little tidbit into your original post! Now, your options are extremely limited... 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