EirikO
July 4th, 2007, 02:14 AM
I use the following code to send a message from a editbox:
CString Msg = m_Msg;
DWORD Length = Msg.GetLength();
m_OutputCtrl.AddString(_T("Sending your message..."));
m_OutputCtrl.AddString(Msg);
//Msg += "\n\r";
int BytesSent = m_MySocket.Send(Msg, Length);
if(BytesSent > 0) {
m_OutputCtrl.AddString(_T("Sending OK"));
}
The problem is that the last characters disapears. I think ceil(length/2) characters comes through... Se table:
What I send | What comes through
a | a
ab | a
abc | ab
abcd | ab
abcde | abc
abcdef | abc
abcdefg | abcd
abcdefgh | abcd
abcdefghi | abcde
123456789123456 | 12345678
Can anyone please help me? The question is, I think, how to find number of bytes in a Cstring...
CString Msg = m_Msg;
DWORD Length = Msg.GetLength();
m_OutputCtrl.AddString(_T("Sending your message..."));
m_OutputCtrl.AddString(Msg);
//Msg += "\n\r";
int BytesSent = m_MySocket.Send(Msg, Length);
if(BytesSent > 0) {
m_OutputCtrl.AddString(_T("Sending OK"));
}
The problem is that the last characters disapears. I think ceil(length/2) characters comes through... Se table:
What I send | What comes through
a | a
ab | a
abc | ab
abcd | ab
abcde | abc
abcdef | abc
abcdefg | abcd
abcdefgh | abcd
abcdefghi | abcde
123456789123456 | 12345678
Can anyone please help me? The question is, I think, how to find number of bytes in a Cstring...