【问题标题】:Error in use of the pcap_findalldevs_ex Function in c++在 c++ 中使用 pcap_findalldevs_ex 函数时出错
【发布时间】:2015-07-01 14:25:34
【问题描述】:

在此程序下方检索适配器列表并将其打印在屏幕上:

 #include <stdio.h>
 #include <pcap.h>  

 int main()  
 {  
     pcap_if_t *alldevs;  
     pcap_if_t *d;  
     int i=0;  
     char errbuf[PCAP_ERRBUF_SIZE];  

     if (pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &alldevs, errbuf) == -1)  
     {  
         fprintf(stderr,"Error in pcap_findalldevs_ex: %s/n", errbuf);  
         exit(1);  
     }  


     for(d= alldevs; d != NULL; d= d->next)  
     {  
         printf("%d. %s", ++i, d->name);  
         if (d->description)  
             printf(" (%s)/n", d->description);  
         else  
             printf(" (No description available)/n");  
     }  

     if (i == 0)  
     {  
         printf("/nNo interfaces found! Make sure WinPcap is installed./n");  
         return 0;  
     }  

     pcap_freealldevs(alldevs);  
 }

编译成功但报错:

【问题讨论】:

    标签: sockets pcap


    【解决方案1】:

    每个人都有这些错误,在使用 pcap.h 时,请转到下面的链接并下载 pcap,然后安装它: http://www.winpcap.org/install/default.htm

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-11
      • 1970-01-01
      相关资源
      最近更新 更多