#include "UDPServer/UDPServer.h" #include #include #include #include #include #include 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 func){ std::thread([func]() { while (true) { func(); } }).detach(); } int main (int argc, char *argv[]){ initLog(); std::string address = "localhost"; int port = 4002; UDPServer server = UDPServer(address, port); std::size_t length{32768}; std::vector buf(16000); std::cout << "Receiving UDP packages: " << std::endl; // for(auto i = 0; i < 27; i++){ // std::function f = [=]() { // server.recv(); // }; // start(); // } 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); BOOST_LOG_TRIVIAL(debug) << "Server: Received " << bytes << " Bytes with Index " << index; } return 0; }