18 Jun
2018
18 Jun
'18
1:12 p.m.
If I initialize an io_service object and a socket object in my header file, how do I pass io_service to the socket as a parameter in my implementation file? Take this header file as an example: // foo.h
#include
class foo { public:
foo(); // Constructor.
private:
boost::asio::io_service ios;
boost::asio::ip::udp::socket sock; };
And the corresponding implementation file: // foo.cc
#include "foo.h"
foo::foo() { sock(ios); // <-- This throws a compiler error. }
Why doing *sock(ios);* doesn't work? What is the proper way to do it? Thank you. Álvaro