Boost asio error message

Basically I'm writing a little app and am getting a strange error from boost. I havent actually written the server part of the code so I know that I won't get the "Connect Successful" message but I wanted to make sure i would get the "Could not connect to socket, exiting..." message. The code is as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class Arguments {
	std::string host;
	std::string port;

public:
	Arguments(char *ptrHost, char *ptrPort) : host(ptrHost), port(ptrPort) {};
	Arguments(char *ptrPort) : port(ptrPort) {};

	std::string getHost() const {
		return host;
	}
	std::string getPort() const {
		return port;
	}
}; 

// start of main etc...
	try {
		Arguments *client = new Arguments(argv[1], argv[2]);
	         using boost::asio::ip::tcp;
				
		boost::asio::io_service io_service;
		tcp::resolver resolve(io_service);
		tcp::resolver::query query(tcp::v4(), client->getHost(), client->getPort());
		tcp::resolver::iterator iterator = resolve.resolve(query);

		tcp::socket Socket(io_service);
		boost::system::error_code connect_error;
		Socket.connect(*iterator, connect_error);
		if(connect_error) {
			std::cout << "Could not connect to socket, exiting...";
			std::cin.get();
			return 1;
		}
		else 
			std::cout << "Connect Successful\n";


The error code I receive is: "The specified class was not found". Maybe I'm being ignorant but that error isn't even particularly helpful.

EDIT** After block-commenting out the code and then going line by line I only get this error once I reach tcp::resolver::iterator iterator = resolve.resolve(query);. Any help would be much appreciated.

EDIT**** I changed the line tcp::resolver::query query(tcp::v4(), client->getHost(), client->getPort()); to tcp::resolver::query query(tcp::v4(), "127.0.0.1", "10000"); and it ran without the error message! I don't understand why this isn't working; the only thing I can think of is in the constructor documentation it says it is expecting a const std::string - am i only apssing it a std::string by using client->getHost()/getPort() ?

EDIT ****** OH DEAR! I fixed the problem; I was using the wrong argv's for the object constructor :|
Last edited on
Topic archived. No new replies allowed.