|
Boost Users : |
Subject: [Boost-users] Boost.Asio, An invalid argument was supplied.
From: stefys (stefys_at_[hidden])
Date: 2008-11-23 05:46:11
Hello. I am trying to write a simple server, and I am using an
asynchronous acceptor to get clients:
acceptor.async_accept(crtclient->getSocket(),
boost::bind(&Server::gotClient, this, boost::asio::placeholders::error));
As soon as this is executed, my Server::gotClient gets called with
ec.message()="An invalid argument was supplied."
Apparently the problem is that I am supplying an invalid socket with
crtClient->getSocket(), but I can't understand how can this be.
crtClient is a boost::shared_ptr<Client>.
class Client {
...
public:
Client (boost::asio::io_service &ioserv, Server &server) :
socket_(ioserv), ... {}
...
boost::asio::ip::tcp::socket &getSocket () { return socket_; }
...
private: boost::asio::ip::tcp::socket socket_;
...
};
What could be wrong? Am I constructing socket incorrectly with
socket_(ioserv)? Because if I construct it with socket_(ioserv,
boost::asio::ip::tcp::v4()), I get the error "Already open" in
ec.message(), rather than "An invalid argument was supplied".
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net