Walter.Net.Networking
ICMPSocket Class
Members  Example 
Walter.Net.Networking Assembly > Walter.Net.Networking Namespace : ICMPSocket Class
Syntax
public class ICMPSocket 
Remarks
ICPM ping is a race condition as the operating system will reply and only using VESNX Kernel-Mode Driver to detect and intecept the events
Example
This code shows how a ping activity is detected
var ip = IPAddress.Parse("192.168.2.5");
// var ip = IPAddress.Loopback;
using var listener = new ICMPSocket(ip);
try
{
    listener.Start();
    listener.OnPingReceived += result =>
    {
        _context?.WriteLine($"{result.MessageType} request received from {result.RemoteEndpoint.Address}");
        if (result is PingListenerResultventArgs ping)
        {
            ping.PoinsonOperatingSytem = PoinsonOperatingSytem.Linux;
        }
        _context?.WriteLine($"{result.MessageType}:{(byte)result.MessageType}");
        _context?.WriteLine($"{result.Code}: {result.Code}");
        _context?.WriteLine("---------RAW--------");
        foreach (var line in result.Data.HexDumps())
        {
            _context?.WriteLine(line);
        }
 
        // Optionally, handle the ping request specifically
    };
 
    listener.PacketReceived += result =>
    {
        _context?.WriteLine($"Received {result.Data.Length} bytes from {result.RemoteEndpoint.Address}");
 
    };
 
    listener.Start();
 
    using var ping = new Ping();
    var answer = await ping.SendPingAsync(ip, 1000);
    _context?.WriteLine($"{answer.Status}: Round trip:{answer.RoundtripTime}");
    foreach (var line in answer.Buffer.HexDumps())
    {
        _context?.WriteLine(line);
    }
}
finally
{
 
    listener.Stop();
}
Inheritance Hierarchy

System.Object
   Walter.Net.Networking.ICMPSocket

Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

ICMPSocket Members
Walter.Net.Networking Namespace