基本信息
源码名称:CSharp Pcap例子WakeOnLan
源码大小:0.03M
文件格式:.zip
开发语言:C#
更新时间:2018-12-26
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 2 元 
   源码介绍

CSharp Pcap的网络唤醒


var devices = CaptureDeviceList.Instance;

            // if no devices were found print an error
            if(devices.Count < 1)
            {
                Console.WriteLine("No devices were found on this machine");
                return;
            }

            Console.WriteLine("The following devices are available on this machine:");
            Console.WriteLine("----------------------------------------------------");
            Console.WriteLine();

            int i = 0;

            // scan the list printing every entry
            foreach(var dev in devices)
            {
                Console.WriteLine("{0}) {1} {2}",i,dev.Name,dev.Description);
                i ;
            }

            Console.WriteLine();
            Console.Write("-- Please choose a device to capture: ");
            i = int.Parse(Console.ReadLine());

            var device1 = devices[i];
            var device2 = CaptureDeviceList.New()[i];

            // register our handler function to the 'packet arrival' event
            device1.OnPacketArrival =
                new PacketArrivalEventHandler(device_OnPacketArrival);
            device2.OnPacketArrival =
                new PacketArrivalEventHandler(device_OnPacketArrival);

            // open the device for capturing
            int readTimeoutMilliseconds = 1000;
            device1.Open(DeviceMode.Promiscuous, readTimeoutMilliseconds);
            device2.Open(DeviceMode.Promiscuous, readTimeoutMilliseconds);

            // tcpdump filter to capture only TCP/IP packets
            device1.Filter = "ether dst FF:FF:FF:FF:FF:FF and udp";
            device2.Filter = "ether dst FF:FF:FF:FF:FF:FF and ether proto 0x0842";

            Console.WriteLine();
            Console.WriteLine("-- Listening for packets... Hit 'Ctrl-C' to exit --");

            // start capture packets
            device1.Capture();
            device2.Capture();