Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void my_connect_handler4(net::socket::tcp::child4 &sock)
- {
- std::cout << "New client connected (IPv4)" << std::endl;
- }
- void my_connect_handler6(net::socket::tcp::child6 &sock)
- {
- std::cout << "New client connected (IPv6)" << std::endl;
- }
- void my_receive_handler4(net::socket::tcp::child4 &sock, net::socket::buffer buffer)
- {
- std::cout << "New data (IPv4) [" << buffer.size() << "]: " << *buffer << std::endl;
- }
- void my_receive_handler6(net::socket::tcp::child6 &sock, net::socket::buffer buffer)
- {
- std::cout << "New data (IPv6) [" << buffer.size() << "]: " << *buffer << std::endl;
- }
- int application::run()
- {
- net::connection_pool pool;
- pool.listen(8080);
- pool.on_connect<net::socket::endpoint>() += my_connect_handler4;
- pool.on_connect<net::socket::endpoint6>() += my_connect_handler6;
- pool.on_receive<net::socket::endpoint>() += my_receive_handler4;
- pool.on_receive<net::socket::endpoint6>() += my_receive_handler6;
- pool.start_accept();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement