ソースを参照

Start sniffing in a seperate thread

anon 4 年 前
コミット
9ed40fff8b
1 ファイル変更4 行追加1 行削除
  1. 4 1
      daemon/src/main.cpp

+ 4 - 1
daemon/src/main.cpp

@@ -2,6 +2,7 @@
 #include <boost/bind.hpp>
 #include <boost/enable_shared_from_this.hpp>
 #include <iostream>
+#include <thread>
 
 #include "../include/Sniffer.h"
 
@@ -96,7 +97,7 @@ int main(int argc, char *argv[]) {
 
   const std::string interface = argv[1];
   Sniffer sniffer(interface);
-  sniffer.startSniffing();
+  std::thread snifferThread(&Sniffer::startSniffing, sniffer);
 
   try {
     io_service io_service;
@@ -105,5 +106,7 @@ int main(int argc, char *argv[]) {
   } catch (std::exception &e) {
     std::cerr << e.what() << endl;
   }
+
+  snifferThread.join();
   return 0;
 }