diff options
author | Tobias Frust <tobiasfrust@gmail.com> | 2016-06-30 15:22:07 +0200 |
---|---|---|
committer | Tobias Frust <tobiasfrust@gmail.com> | 2016-06-30 15:22:07 +0200 |
commit | 0c33319451deec9b5461b57856423bc619817245 (patch) | |
tree | 2d5be787fb4d4e052e72aaf01ccf095874c46f2e /src/main_server.cpp | |
parent | dbf28e725f062744222559257abe64d8a39a9d50 (diff) | |
download | ods-0c33319451deec9b5461b57856423bc619817245.tar.gz ods-0c33319451deec9b5461b57856423bc619817245.tar.bz2 ods-0c33319451deec9b5461b57856423bc619817245.tar.xz ods-0c33319451deec9b5461b57856423bc619817245.zip |
added classes for detector; Sending out in n different streams with n different ports
Diffstat (limited to 'src/main_server.cpp')
-rw-r--r-- | src/main_server.cpp | 56 |
1 files changed, 44 insertions, 12 deletions
diff --git a/src/main_server.cpp b/src/main_server.cpp index 167dfca..a645f49 100644 --- a/src/main_server.cpp +++ b/src/main_server.cpp @@ -1,28 +1,60 @@ #include "UDPServer/UDPServer.h" +#include <boost/log/core.hpp> +#include <boost/log/trivial.hpp> +#include <boost/log/expressions.hpp> + #include <iostream> #include <string> +#include <thread> + +void initLog() { +#ifndef NDEBUG + boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::debug); +#else + boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::info); +#endif +} + +void start(std::function<void(void)> func){ + std::thread([func]() { + while (true) + { + func(); + } + }).detach(); +} int main (int argc, char *argv[]){ - std::cout << "Receiving UDP packages: " << std::endl; + initLog(); + + std::string address = "localhost"; + int port = 4002; + + UDPServer server = UDPServer(address, port); - std::string address = "10.0.0.10"; - int port = 4000; + std::size_t length{32768}; - UDPServer server = UDPServer(address, port); + std::vector<unsigned short> buf(16000); - std::size_t length{16*500}; + std::cout << "Receiving UDP packages: " << std::endl; - unsigned short buf[length]; +// for(auto i = 0; i < 27; i++){ +// std::function<void(void)> f = [=]() { +// server.recv(); +// }; +// start(); +// } - server.recv((char *)buf, length*sizeof(unsigned short)); + while(true){ + int bytes = server.recv((char*)buf.data(), length); + std::size_t index = *((std::size_t *)buf.data()); + if(index%1000 == 99) printf("%lu\n", index); - for(auto i = 0; i < length; i++){ - printf("%i ", buf[i]); - } - printf("\n"); + BOOST_LOG_TRIVIAL(debug) << "Server: Received " << bytes << " Bytes with Index " << index; + } - return 0; + return 0; } |