Sockets trouble in Visual Studio 2008
-
My guess would be that the 'from scratch in VS2008' version uses Unicode, the 'upgraded from VS6' one uses ASCII. I can see various places where you are (incorrectly) assuming ASCII, but the killer is in CSocketsDlg::OnReceive. Where you read a number of bytes and then append to a CString. The string you've received will have '\0' characters in it, because it's a wchar_t string that you've interpreted as char, so when you append it to a CString, the rlevant method will use strlen to find the string length, see the zero byte after the first character and say 'Aha, that's the end of the string!' - but not where you a) wanted, or b) expected. So - fix the ASCII assumptions, man!!!! Or turn off Unicode
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
Here's some data sent and received b/w both applications and their versions->
( Visual studio 6 ) ( VS 2008 Pro )
sent recvd | sent recvd
123456789 | 123456789
1 123456789
I hope this will give u a clear understanding about my BUG. If u compile these applications then u should get these results.
Manmohan Bishnoi
-
Here's some data sent and received b/w both applications and their versions->
( Visual studio 6 ) ( VS 2008 Pro )
sent recvd | sent recvd
123456789 | 123456789
1 123456789
I hope this will give u a clear understanding about my BUG. If u compile these applications then u should get these results.
Manmohan Bishnoi
monu_biosman wrote:
I hope this will give u a clear understanding about my BUG.
I already understand what your bug is, well enough that I told you how to fix it - either turn off Unicode in your app developed from scratch with VS2008, or make your usage of Unicode/ASCII strings consistent.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
monu_biosman wrote:
I hope this will give u a clear understanding about my BUG.
I already understand what your bug is, well enough that I told you how to fix it - either turn off Unicode in your app developed from scratch with VS2008, or make your usage of Unicode/ASCII strings consistent.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
how to turnoff Unicode in current project in VS 2008 Pro
Manmohan Bishnoi
-
how to turnoff Unicode in current project in VS 2008 Pro
Manmohan Bishnoi
Select the project in solution explorer, right-click on it and select Properties from the context menu. Now go to the Configuration Properties->General property page and set the Character Set property to 'Use Multi-Byte Character Set'
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
Select the project in solution explorer, right-click on it and select Properties from the context menu. Now go to the Configuration Properties->General property page and set the Character Set property to 'Use Multi-Byte Character Set'
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
Debug version is working ok but not having xp common controls look. Release version not working ok but having xp common controls manifest.
Manmohan Bishnoi
-
Debug version is working ok but not having xp common controls look. Release version not working ok but having xp common controls manifest.
Manmohan Bishnoi
Did you change the property for Debug AND Release configurations - the properties are (unfortunately, in many ways) set separately.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
Debug version is working ok but not having xp common controls look. Release version not working ok but having xp common controls manifest.
Manmohan Bishnoi
And the manifest file...ummm - is the project property Configuration Properties->Linker->Manifest File->Generate Manifest set to Yes in all cases? Although it may be that XP themes need Unicode.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
And the manifest file...ummm - is the project property Configuration Properties->Linker->Manifest File->Generate Manifest set to Yes in all cases? Although it may be that XP themes need Unicode.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
done as u told me to do. But no use. Anyway atleast debug version got somewhat debugged.
Manmohan Bishnoi
-
done as u told me to do. But no use. Anyway atleast debug version got somewhat debugged.
Manmohan Bishnoi
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
-
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