
util::net::read_non_blocking(Module::_socket, buffer(buf, 4), 1);
Note that it's *blocking* read with timeout.
undefined reference to `boost::optional<boost::system::error_code> util::net::read_non_blocking<boost::asio::mutable_buffers_1>(boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >*, boost::asio::mutable_buffers_1 const&, int)
Maybe you tried to define the function template in cpp, without explicit specialization. Define your function templates in the header.
Also, what will this code return exacty?
What do you mean by saying "return"? The function attempts to read data to the buffer you suplly, and if the operation doesn't complete in some time-interval, it throws an exception.