public ICMPSocket( IPAddress address, CancellationToken cancellationToken )
Parameters
- address
- the address to listen on
- cancellationToken
- the cancelation token to listen to for canelation
public ICMPSocket( IPAddress address, CancellationToken cancellationToken )
public void Listen() { if (_terminate) { Shutdown(); } _terminate = false; if (_cancellationToken is not null) _cancellationToken.Dispose(); _cancellationToken = new CancellationTokenSource(); if (_options.MonitorProtocol.HasFlag(PortAccessProtocols.TcpIp)) { Task.Run(() => StartTcpListener(_cancellationToken.Token)).Forget(); } if (_options.MonitorProtocol.HasFlag(PortAccessProtocols.Udp)) { Task.Run(() => StartUdpListener(_cancellationToken.Token)).Forget(); } if (_options.MonitorProtocol.HasFlag(PortAccessProtocols.ICMP)) { _iCMPSockets = new List<ICMPSocket>(); Inverse.TryResolve<ILoggerFactory>(out var factory); foreach (var ip in LocalNetwork.LocalIPAddresses()) { _iCMPSockets.Add(new ICMPSocket(ip,_cancellationToken.Token)); _iCMPSockets[^1].PacketReceived += OnPinged; _iCMPSockets[^1].Logger = factory?.CreateLogger("Walter.Net.Networking.ICMPSocket.") ?? _logger; _iCMPSockets[^1].Start(); } } }
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