void do_read_header() { auto self(shared_from_this()); boost::asio::async_read(socket_, boost::asio::buffer(header_data_, HEADER_LENGTH), [this, self](boost::system::error_code ec, std::size_t) { if (!ec) { do_read_body(decode_header()); } } ); }
void ChatClient::do_read_header() { boost::asio::async_read(socket_, boost::asio::buffer(read_msg_.data(), ChatMessage::header_length), [this](boost::system::error_code ec, size_t /*length*/) { if (!ec && read_msg_.decode_header()) do_read_body(); else socket_.close(); }); }
void chat_client::do_read_header() { asio::async_read(socket_, asio::buffer(read_msg_.data(), ChatMessage::header_length), [this](std::error_code ec, std::size_t /*length*/) { if (!ec && read_msg_.decode_header()) { do_read_body(); } else { socket_.close(); } }); }
void chat_client::do_read_header() { boost::asio::async_read(socket_, boost::asio::buffer(read_msg_.data(), chat_message::header_length), [this](boost::system::error_code ec, std::size_t) { if (!ec && read_msg_.decode_header()) { do_read_body(); } else { socket_.close(); } }); }
void TCPClient::do_read_header() { //La lectura asíncrona requiere de el socket, el buffer que parte de los datos y la longitud que va a leer, que en este caso es el header. Además requiere una función que haga de handler boost::asio::async_read(socket_,boost::asio::buffer(read_msg_.data(), Message::header_length), [this](boost::system::error_code ec, std::size_t /*length*/) { if (!ec && read_msg_.decode_header()) { do_read_body(); } else { socket_.close(); } }); }
void do_read_header() { boost::asio::async_read( socket_, boost::asio::buffer(read_msg_.data(), chat_message::HEADER_LENGTH), [this](boost::system::error_code ec, std::size_t) { if (ec) { std::cout << ec.message() << "\n"; if (ec != boost::asio::error::operation_aborted) { socket_.close(); } return; } if (!read_msg_.decode_header()) { socket_.close(); return; } do_read_body(); }); }
void do_read_header() { auto self(shared_from_this()); int num; if ((num = recv(m_arg->connectfd, m_read_msg.data(), ChatMessage::header_length, 0)) == 0) { std::cerr << "Wrong,client disconnectfd.\n"; close(m_arg->connectfd); return; } if (m_read_msg.decode_header()) { do_read_body(); } else { m_room.leave(shared_from_this()); } /*client_name[num] = '\0'; std::cout << "You got aconnection from " << inet_ntoa(m_arg->client.sin_addr) << ",client's name is " << client_name << std::endl;*/ }