ping timeout and retries

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:Courier New;background-color:white
<table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0>
<colgroup>
<col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:Courier New;white-space:nowrap
<tbody>
<tr>
<td>
<p align=left><font style="font-size:11px using System;  </font> </td></tr>
<tr>
<td style="background-color:#f7f7f7 using System.Text;  </td></tr>
<tr>
<td>using System.Net;  </td></tr>
<tr>
<td style="background-color:#f7f7f7 using System.Net.NetworkInformation;  </td></tr>
<tr>
<td> </td></tr>
<tr>
<td style="background-color:#f7f7f7 namespace PingExperiment {  </td></tr>
<tr>
<td>    class PingExperiment {  </td></tr>
<tr>
<td style="background-color:#f7f7f7  </td></tr>
<tr>
<td>        public static void Main(string[] args) {  </td></tr>
<tr>
<td style="background-color:#f7f7f7             Ping </font><font style="color:red ping</font><font style="font-size:11px  = </font><font style="color:blue new</font><font style="font-size:11px  Ping();  </font></td></tr>
<tr>
<td>            int </font><font style="color:red timeout</font><font style="font-size:11px  = </font><font style="color:blue 500</font><font style="font-size:11px ;  </font></td></tr>
<tr>
<td style="background-color:#f7f7f7             int </font><font style="color:red msStartTime</font><font style="font-size:11px  = </font><font style="color:blue Environment</font><font style="font-size:11px .TickCount;  </font></td></tr>
<tr>
<td>            try {  </td></tr>
<tr>
<td style="background-color:#f7f7f7                 ping.Send("nonexistenthost", timeout);  </td></tr>
<tr>
<td>            } catch (Exception e) {  </td></tr>
<tr>
<td style="background-color:#f7f7f7                 Console.WriteLine(e.Message);  </td></tr>
<tr>
<td>            }  </td></tr>
<tr>
<td style="background-color:#f7f7f7             int </font><font style="color:red msEndTime</font><font style="font-size:11px  = </font><font style="color:blue Environment</font><font style="font-size:11px .TickCount;  </font></td></tr>
<tr>
<td>            Console.WriteLine("ping timeout was {0}. ping took {1}", timeout, msEndTime - msStartTime);  </td></tr>
<tr>
<td style="background-color:#f7f7f7         }  </td></tr>
<tr>
<td> </td></tr>
<tr>
<td style="background-color:#f7f7f7     }  </td></tr>
<tr>
<td>} </td></tr></tbody></table> <font size=2>I am confused regarding ping timeout. It takes longer than expected. Is it retrying 3 or 4 times? I could not see a way to set retries.

The code above produces the following output.
</font>
<div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:Courier New;background-color:white
<table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0>
<colgroup>
<col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:Courier New;white-space:nowrap
<tbody>
<tr>
<td><font style="font-size:11px An exception occurred during a Ping request.  </font></td></tr>
<tr>
<td style="background-color:#f7f7f7 ping timeout was 500. ping took 2297 </td></tr></tbody></table>


View the full article
 
Back
Top