System.Net.ArpRequest.Send C# (CSharp) Method

Send() public static method

Sendet eine Anfrage über das ARP-Protokoll, um eine IP-Adresse in die Physikalische Adresse aufzulösen. Falls sich die physikalische Adresse bereits im Cache des Hosts befindet, wird diese zurückgegeben.
public static Send ( IPAddress destination ) : ArpRequestResult
destination IPAddress Destination .
return ArpRequestResult
        public static ArpRequestResult Send(IPAddress destination)
        {
            if (destination == null)
                throw new ArgumentNullException(nameof(destination));

            int destIp = BitConverter.ToInt32(destination.GetAddressBytes(), 0);

            var addr = new byte[6];
            var len = addr.Length;

            var res = NativeMethods.SendARP(destIp, 0, addr, ref len);

            if (res == 0)
                return new ArpRequestResult(new PhysicalAddress(addr));
            return new ArpRequestResult(new Win32Exception(res));
        }

Usage Example

示例#1
0
 /// <summary>
 /// Sendet eine Anfrage über das ARP-Protokoll, um eine IP-Adresse in die Physikalische Adresse aufzulösen. Falls sich die physikalische Adresse bereits im Cache des Hosts befindet, wird diese zurückgegeben.
 /// </summary>
 /// <param name="destination">Destination <see cref="IPAddress"/>.</param>
 /// <returns>Eine <see cref="T:System.Net.ArpRequestResult">ArpRequestResult</see>-Instanz, welche die Ergebnisse der Anfrage enthält.</returns>
 public static ArpRequestResult SendArpRequest(this IPAddress destination) => ArpRequest.Send(destination);