Guys I really need your help. I'm learning boost::asio
and I have 2 problems that I can't deal for days...
Here is an example of a simple echo server done by myself:
int main(
{
// crate a server, binding it and listening connections
// acceptor server;
//socket client
server.async_accept(client, boost::bind(accept_handle, _1, &server, &client));
io_service.run();
return 0;
}
void accept_handle(const boost::system::error_code& eCode, boost::asio::ip::tcp::acceptor* server, boost::asio::ip::tcp::socket* client)
{
char data[43];
client->async_read_some(boost::asio::buffer(data, 20), boost::bind(read_handle, _1, _2, server, client));
}
void read_handle(const boost::system::error_code& eCode, size_t bytes)
{
char data_buf[20] = "hello";
client->async_write_some(boost::buufer(data, 5), boost::bind(write_handle, _1, _2, server, client));
}
void write_accept(const boost::system::error_code& eCode, size_t bytes)
{
boost::asio::ip::tcp::socket newConnection(server->get_ioservice)); // taking he io_service of the server
server->async_accept(newConnection, boost::bind(accept_handle, _1, server, client));
}
The problem is the server accept one client and it does not accept other pending client.. where am i doing wrong here
NOTE: I wrote this code in notepad so sorry for syntax errors if there are any.
Thanks for your help in advance!!!