I am having trouble getting Poco::FIFOBuffer.read() to work. Either getting access violation errors or stack around the variable result was corrupted.
std::string output;
Poco::FIFOBuffer recvData(BUFFERLEN);
int iResult = mySockets[vect[2]]->receiveBytes(recvData);
char* result = "";
std::cout << recvData.read(result, recvData.size());
output = result;
elswhere in the program a very similar thing seems to work fine (vect is a vector ) mySockets is a Map
Poco::FIFOBuffer sendData(BUFFERLEN, false);
sendData.copy(vect[3].c_str(), vect[3].size());
int iResult = mySockets[vect[2]]->sendBytes(sendData);
output = "data sent, sendBytes returned: " + std::to_string(iResult);
reference:http://pocoproject.org/docs-1.5.0/Poco.BasicFIFOBuffer.html#11400
As stated in the comment above, the documentation is wrong.
If you want the buffer to be automatically resized use
Poco::Buffer<char>
; alternatively, make sure that thechar*
points to enough space to accommodate the data (which is tricky - you'll have to query the FIFOBuffer to find out how much didreceiveBytes()
call return, so usingPoco::Buffer
is an easier option).