
Benjamin Sobotta wrote:
Hello,
It would be interesting to know *how* you exactly transfer the information at hand and then build a solution from there.
Anyways, I use ASIO in conjunction with boost::serialization. There is an example on the ASIO website. I found that combination extremely handy. With this approach one could easily transfer any kind of data, for example in a std::vector.
hth,
Benjamin
Hi Benjamin,
Find below the relevant snippets of the client and the server code. As
you can see, I keep on sending parameters, separated by newlines. Two
consecutive newlines denote end of input. This obviously does not scale
to a more complex transfer (i.e., a complete binary file).
Thanks for your kind assistance,
-Ramon
----------------------------------------
Client:
// stream
boost::asio::streambuf buf;
std::ostream net_out(&buf);
// Display the arguments
if (debug()) cout << "client pushing " << argc - 1 << "
arguments" << endl;
for (int i = 1; i < argc; i++) {
net_out << argv[i] << endl;
if (debug()) cout << "arg[" << i << "], " << argv[i] << "
was pushed" << endl;
}
net_out << endl;
boost::asio::write(socket, buf);
while (true) {
boost::array