PingOptions Constructor (Int32, Boolean)
Initializes a new instance of the PingOptions class and sets the Time to Live and fragmentation values.
Assembly: System (in System.dll)
Parameters
- ttl
-
Type:
System::Int32
An Int32 value greater than zero that specifies the number of times that the Ping data packets can be forwarded.
- dontFragment
-
Type:
System::Boolean
true to prevent data sent to the remote host from being fragmented; otherwise, false.
| Exception | Condition |
|---|---|
| ArgumentOutOfRangeException | ttl is less than or equal to zero. |
The ttl parameter limits the number of routers and gateways that can forward the data. This is useful for testing the length of the route between the local and remote computers. The dontFragment parameter allows you to test the maximum transmission unit (MTU) of the routers and gateways used to transmit the packet.
The following code example demonstrates calling this constructor and displaying the new instance's property values.
// Set options for transmission: // The data can go through 64 gateways or routers // before it is destroyed, and the data packet // cannot be fragmented. PingOptions ^ options = gcnew PingOptions( 64,true ); Console::WriteLine( "Time to live: {0}", options->Ttl ); Console::WriteLine( "Don't fragment: {0}", options->DontFragment );
Available since 2.0