I am creating a Socket class that uses boost::asio . To get started, I made a connect method that took the host and port and resolved it to an IP address. This worked well, so I decided to look at async_resolve . However, my callback always gets error code 995 (using the same destination host / port as when working synchronously).
code
Function that triggers resolution:
The code calling this function:
void Socket::connect(const String& _host, Port _port) { // Anon function for resolution of the host-name and asynchronous calling of the above auto anonResolve = [this](const boost::system::error_code& _errorCode, boost::asio::ip::tcp::resolver_iterator _epIt) { // raise event onResolve.raise(SocketResolveEventArgs(*this, !_errorCode ? (*_epIt).host_name() : String(""), _errorCode)); // perform connect, calling back to anonymous function if(!_errorCode) connect(*_epIt); }; // Resolve the host calling back to anonymous function Root::instance().resolveHost(_host, _port, anonResolve); }; // eo connect
Function message() error_code :
The I/O operation has been aborted because of either a thread exit or an application request
And my main.cpp looks like this:
int _tmain(int argc, _TCHAR* argv[]) { morse::Root root; TextSocket s; s.connect("somehost.com", 1234); while(true) { root.performIO();
Thanks in advance!
source share