Attempts to send an Internet Control Message Protocol (ICMP) echo message with the specified data buffer to the specified computer, and receive a corresponding ICMP echo reply message from that computer. This overload allows you to specify a time-out value for the operation and control fragmentation and Time-to-Live values for the ICMP packet.
- hostNameOrAddress
- A string that identifies the computer that is the destination for the ICMP echo message. The value specified for this parameter can be a host name or a string representation of an IP address.
- timeout
- An int value that specifies the maximum number of milliseconds (after sending the echo message) to wait for the ICMP echo reply message.
- buffer
- A byte array that contains data to be sent with the ICMP echo message and returned in the ICMP echo reply message. The array cannot contain more than 65,500 bytes.
- options
- A System.Net.NetworkInformation.PingOptions object used to control fragmentation and Time-to-Live values for the ICMP echo message packet.
A System.Net.NetworkInformation.PingReply object that provides information about the ICMP echo reply message if one was received, or provides the reason for the failure if no message was received.
If the ICMP echo reply message is not received within the time specified by the timeout parameter, the ICMP echo fails, and the PingReply.Status property is set to IPStatus.TimedOut.
When specifying very small numbers for timeout, the Ping reply can be received even if timeout milliseconds have elapsed.
If the PingOptions.DontFragment property is true and the total packet size exceeds the maximum packet size that can be transmitted by one of the routing nodes between the local and remote computers, the ICMP echo request fails. When this happens, the PingReply.Status is set to IPStatus.PacketTooBig.
Use the PingOptions.Ttl property to specify the maximum number of times the ICMP echo message can be forwarded before reaching its destination. If the packet does not reach its destination after being forwarded the specified number of times, the packet is discarded and the ICMP echo request fails. When this happens, the PingReply.Status is set to IPStatus.TtlExpired.