6 Replies - 1906 Views - Last Post: 23 September 2012 - 04:40 AM Rate Topic: -----

#1 naori  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 22-September 12

sending a infinity ping command

Posted 22 September 2012 - 12:53 PM

Hello all i'm new here.
I'm using windows forms application.
I'm trying to send a infinity ping to server.
actually I can send it under the FormLoad but it runs once apparently.
this is my code:
private void Form1_Load(object sender, EventArgs e)
        {
            Ping ping = new Ping();
            PingReply pingReply = ping.Send("10.0.0.138");
                if (pingReply.Status == IPStatus.Success)
                    button1.BackColor = Color.Green;
                else
                    button1.BackColor = Color.Red;
        }


How can I use it all the time when the application is running?
thank u all.

MOD EDIT: Added code tags. When posting code...USE CODE TAGS!!!

:code:

This post has been edited by JackOfAllTrades: 23 September 2012 - 04:36 AM


Is This A Good Question/Topic? 0
  • +

Replies To: sending a infinity ping command

#2 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3177
  • View blog
  • Posts: 9,632
  • Joined: 05-May 12

Re: sending a infinity ping command

Posted 22 September 2012 - 01:03 PM

Use a timer, or start a thread.

Make sure that you aren't inadvertently setting up a denial of service on the server if there are going to be lots of people running your program.
Was This Post Helpful? 0
  • +
  • -

#3 Michael26  Icon User is offline

  • Radar love
  • member icon

Reputation: 332
  • View blog
  • Posts: 1,421
  • Joined: 08-April 09

Re: sending a infinity ping command

Posted 22 September 2012 - 02:22 PM

Quote

Make sure that you aren't inadvertently setting up a denial of service on the server if there are going to be lots of people running your program.


Don't you usually close this kinda threads?
Was This Post Helpful? 0
  • +
  • -

#4 naori  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 22-September 12

Re: sending a infinity ping command

Posted 22 September 2012 - 04:23 PM

Skydiver, can you go into detail please?
Was This Post Helpful? 0
  • +
  • -

#5 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3177
  • View blog
  • Posts: 9,632
  • Joined: 05-May 12

Re: sending a infinity ping command

Posted 22 September 2012 - 07:54 PM

Using a timer: http://msdn.microsof...orms.timer.aspx

Creating a thread using TaskFactory: http://msdn.microsof...y/dd321439.aspx

View PostMichael26, on 22 September 2012 - 02:22 PM, said:

Quote

Make sure that you aren't inadvertently setting up a denial of service on the server if there are going to be lots of people running your program.


Don't you usually close this kinda threads?


Our friendly Klingon has amazingly good instincts for sniffing out attempts at writing malware. Perhaps he's busy sharpening his bat'leth right now for such an eventuality.
Was This Post Helpful? 2
  • +
  • -

#6 Michael26  Icon User is offline

  • Radar love
  • member icon

Reputation: 332
  • View blog
  • Posts: 1,421
  • Joined: 08-April 09

Re: sending a infinity ping command

Posted 23 September 2012 - 01:56 AM

Ni'tokor bak'to
From episode Firstborn

This post has been edited by Michael26: 23 September 2012 - 01:58 AM

Was This Post Helpful? 0
  • +
  • -

#7 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 5960
  • View blog
  • Posts: 23,235
  • Joined: 23-August 08

Re: sending a infinity ping command

Posted 23 September 2012 - 04:40 AM

View PostMichael26, on 22 September 2012 - 05:22 PM, said:

Quote

Make sure that you aren't inadvertently setting up a denial of service on the server if there are going to be lots of people running your program.


Don't you usually close this kinda threads?


It's not clear the OP is trying to perform a DOS. There is definite value in the ability to ping a remote system on a timed basis, although depending on the remote system the value of this specific action is questionable. For example, ICMP may be blocked upstream of the remote system. If it's a web server, the ability to ping the system speaks nothing of its ability to respond to web requests; testing connectivity in such a case is better served by performing periodic HTTP HEAD requests to a page on the server and evaluating the HTTP status code returned.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1