Hi,i want to test the following function in POCO:sendTo -> Returns the number of bytes sent, which may be less than the number of bytes specified.
1 2 3 4 5 6
int sendTo(constvoid* buffer, int length, const SocketAddress& address, int flags = 0);
/// Sends the contents of the given buffer through
/// the socket to the given address.
///
/// Returns the number of bytes sent, which may be
/// less than the number of bytes specified.
Server.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14
//Sends the contents of the given buffer through the socket to the given address.
int nMsgSize = outgoing.length(); //return nMsgSize = 100
//To test send the partial message
std::string teststr = outgoing.substr(0,5);
int nTestSize = teststr.length(); //return nTestSize = 5;
int nSendBytes = _socket.sendTo(teststr.c_str(), nMsgSize, _group);
//MY PROBLEM: nSendBytes is always return 100(nMsgSize) not 5(teststr.length())
//So the following statement will not call.
if (nSendBytes < nMsgSize)
{
std::string balstr = outgoing.substr(nSendBytes);
}
Maybe i should ignore the return size(nSendBytes) and continue send the next new message rather than send the (remaining message + new message) on next package.
I send the single FAST message per packet; the client may not receive the actual nSendBytes too. in this case, the client application should ignore it and decode the next packet.