Hello guys,
i am writing a private server in c++ and i searched a library for networking. Boost was referenced really often so i used it. Now i want to write something to the socket by using boost::asio::async_write(). The problem is that i need to concat 3 things. The first thing is a string the second thing an string and the third a string aswell. I tried this:
Where x[1] is a vector containing the userid as a string! which was optained by the package of a client.
It told me that there is no + operator so i searched how to concat things "into" a buffer. Google came up with something like this:
Again x[1] is the userid.
The program compiles but as soon as it sends the package i get the following messagebox and i don't know what to do about it :
---------------------------
Microsoft Visual C++ Runtime Library
---------------------------
Debug Assertion Failed!
Program: C:\Windows\system32\MSVCP110D.dll
File: c:\program files (x86)\microsoft visual studio 11.0\vc\include\vector
Line: 72
Expression: vector iterator not dereferencable
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
---------------------------
Abbrechen Wiederholen Ignorieren
---------------------------
I hope someone can help me about that.
i am writing a private server in c++ and i searched a library for networking. Boost was referenced really often so i used it. Now i want to write something to the socket by using boost::asio::async_write(). The problem is that i need to concat 3 things. The first thing is a string the second thing an string and the third a string aswell. I tried this:
Code:
boost::asio::async_write(sock,boost::asio::buffer("RDY|I|" + x[1] + "|Beta_Test|10|360|300000|300000|265000|265000|100|300|1000|1000|1|3|0|1500|900|15|0|1337|1337|21|1337|1337|1337|21|lol|3|2|0|50|25"),write_handler);
It told me that there is no + operator so i searched how to concat things "into" a buffer. Google came up with something like this:
Code:
std::vector<boost::asio::const_buffer> buffers;
buffers.push_back(boost::asio::buffer("RDY|I|"));
buffers.push_back(boost::asio::buffer(x[1]));
buffers.push_back(boost::asio::buffer("|Beta_Test|10|360|300000|300000|265000|265000|100|300|1000|1000|1|3|0|1500|900|15|0|1337|1337|21|1337|1337|1337|21|lol|3|2|0|50|25"));
boost::asio::async_write(sock,boost::asio::buffer(buffers),write_handler);
The program compiles but as soon as it sends the package i get the following messagebox and i don't know what to do about it :
---------------------------
Microsoft Visual C++ Runtime Library
---------------------------
Debug Assertion Failed!
Program: C:\Windows\system32\MSVCP110D.dll
File: c:\program files (x86)\microsoft visual studio 11.0\vc\include\vector
Line: 72
Expression: vector iterator not dereferencable
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
---------------------------
Abbrechen Wiederholen Ignorieren
---------------------------
I hope someone can help me about that.