Client is writing like this
std::string line;
std::cin>>line;
boost::asio::write(socket, boost::asio::buffer(line));
Server is Reading like this
void reader(){
socket_.async_read_some(boost::asio::buffer(buf),
boost::bind(&tcp_connection::handle_read,shared_from_this()));
}
void handle_read()
{
std::cout.write(buf.data(),1024);
std::cout<<"\n";
}
tcp::socket socket_;
boost::array<char, 1024> buf;
Now when i am writing a line "hello how are you" from client , it is just printing "hello" and then garbage values
here is the output which server is showing:
helloA0�B��B�����a�Pa�!0�B�b����uB�`�#K|BP�b��D4B���Bb�Pa���e��e�����pc�!0�Be���xB�`�#KcBe�:7B�����e��e���
how can I remove this garbage values and get complete message/line from client
Aucun commentaire:
Enregistrer un commentaire