Ok, I've found the answer to my problem on another forum:
iLen = m\_strMessage.GetLength();
CStringA ansiString(m\_strMessage);//one freaking conversion!
iSent = m\_sConnectSocket.Send(ansiString, iLen);
Works prefectly! :-D
Ok, I've found the answer to my problem on another forum:
iLen = m\_strMessage.GetLength();
CStringA ansiString(m\_strMessage);//one freaking conversion!
iSent = m\_sConnectSocket.Send(ansiString, iLen);
Works prefectly! :-D
Hi. I'm stuck with the same problem. Whenever my program receives data from any tcp/ip server, it displays it correctly, but when it sends data back to the server, the latter receives only the first character. Turning off Unicode is not an option, becouse the tcp/ip communication is only a small part of the project, and this change generates lots of other errors. I'm also using the tutorial from David Chapman's "Teach yourself Visual C++ 6...", and Visual Studio 2k8, so my code is almost exactly the same as monu_biosman's. I'd like to ask Stuart, or anyone else for that matter, what exactly I need to change to make it work. I already made lots of tests, but none seem to work.
//original code: (m_strMessage is a CString)
iLen = m_strMessage.GetLength();
iSent = m_sConnectSocket.Send(LPCTSTR(m_strMessage), iLen);
//I've been changing the iLen, and it's not the problem. Then I've tried:
iSent = m_sConnectSocket.Send("blablabla", 9);
//and it works!!!. But then I've tried the seemingly same code:
CString buffer = "blablabla";
iSent = m_sConnectSocket.Send(buffer, 9);
//and it also sends only one character (b to be exact). So the problem can propably be solved by adding //some type of conversion. So far i've tried this:
char[1024] buffer;
wsprintf(buffer,"%s",m_strMessage);
iSent = m_sConnectSocket.Send(m_strMessage, 1024);
//and.. it does not compile, C2664 error, "'wsprintfW' : cannot convert parameter 1 from 'char [1024]' to 'LPWSTR'"
I'm running out of ideas, or maybe I'm a retard i don't know. Any help would be greatly appreciated. Thanks in advance. SquiZZlo