title: How do I make libpcap/pcap_loop non-blocking?
body: <p>I'm currently using libpcap to sniff traffic in promiscuous mode </p>
  
  <pre><code>int main() 
  {
      // some stuff
      printf("Opening device: %s\n", devname.c_str());
  
      handle = pcap_open_live(devname.c_str(), 65536 , 1 , 0 , errbuf);
  
      if (handle == NULL)
      {
          fprintf(stderr, "Couldn't open device %s : %s..." , devname.c_str(), errbuf);
          return 1;
      }
      printf(" Done\n");
  
      pcap_loop(handle , -1 , process_packet , NULL);
      // here run a thread to do some stuff. however, pcap_loop is blocking
      return 0;
  }
  </code></pre>
  
  <p>I'd like to add an external thread to do some other stuff. How do I change the code above to make it non-blocking?</p>