Reputation: 149
I am using this code http://www.boost.org/doc/libs/1_42_0/doc/html/boost_asio/tutorial/tutdaytime1/src.html in order to make a client and talk to a server.
I am using the following code to send a message
boost::asio::write(socket, boost::asio::buffer(msg), ignored_error);
The problem that I have is that if I declare a string msg= "test 123"; and send it, the server will get "test 123" But if if use cin << msg and input test 123 the server receives two messages :
test
123
The same applies for char[]
I am compiling at C++ 11 if it does matter using -lboost_system parameters
Upvotes: 2
Views: 186
Reputation: 409166
Input with >>
separates on space. So input like test 123
will need two reads using >>
.
If you want to read a whole line then use std::getline
.
Upvotes: 1