Click here to Skip to main content
15,911,039 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi I used this code to ping ip address
And i display msg ok if it replay
And request time out when not
My issue that iwant to replay only one time !

My code
Ping ping = new ping();
PingReply pingresult = ping.send(10.10.10.10);

How can i ping only one time
Something like
Ping 10.10.10.10 -n 1
Posted

According to Ping Class (System.Net.NetworkInformation)[^], there is no option to specify a count. You could maybe use Ping.PingCompleted Event (System.Net.NetworkInformation)[^] to achieve something similar.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 20-Jan-16 18:28pm    
Sure, a 5.
—SA
sam9787 27-Jan-16 14:34pm    
how can i use this ?
Richard MacCutchan 28-Jan-16 4:27am    
By following the link I gave you and reading the documentation.
ok thanks
i solve it

C#
string IP = this.txtIPaddress.Text;
           Ping ping = new Ping();
           int timeout = 1000;
           PingReply pingresult1 = ping.Send(IP,timeout);




using timeout :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900