udp_client::udp_client(boost::asio::io_service& io_service, brain *brain) : client_port(getConfigValue<int>("clientPort")), server_port(getConfigValue<int>("serverPort")), server_host_name(getConfigValue<char*>("serverHostName")), socket_client(io_service, udp::endpoint(udp::v4(), client_port)) { BOOST_LOG_TRIVIAL(info) << "UDP Client started at port : " << client_port; // Resolve hostname to IP (Eg: nao5.local to 10.0.7.5) and attach io service from main thread server_endpoint = endpoint_resolver(io_service, server_host_name, server_port); // Send message to the server. Message is a string that is 01 to initate Hand Tracker boost::shared_ptr<std::string> message(new std::string("01")); send(message); //Reference Brain Module brain_ = brain; // Start a thread for Websocket boost::thread socket_thread(boost::bind(&websocket_server::init, &ws_socket)); }
void SocketServer::Run() { std::thread socket_thread(&SocketServer::execute, this); socket_thread.detach(); }