|
Tam dam daaaam!!!
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world.
Fry: But this is HDTV. It's got better resolution than the real world <
|
|
|
|
|
His function signature is CString CSMTP::get_response() so the return statement will construct a CString with buf and return it. The problem is not in that construct, it was that buf was not null terminated as expected by the constructor. See previous thread for more
Edit: Just seen that the OP code now initializes buf to empty, so the problem is elsewhere, probably around a call to CMemFile::Free() .
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
modified on Wednesday, November 17, 2010 11:02 AM
|
|
|
|
|
Yep, you're right (I've overlooked the signature).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi,
Please post and introduce yourself in General Indian forum[^]
In GIT,we would be able to guide with basic guidelines about posting in Codeprojects.
cheers,
Super
------------------------------------------
Too much of good is bad,mix some evil in it
|
|
|
|
|
Why not set a breakpoint on the first statement in this function and then use the debugger to single-step through the code?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
hi friends,
i am a beginner in C++.
Can any one give me an idea about the use of #ifndef and #define ?
|
|
|
|
|
|
See here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hi all,
in my application this execption occur please describe me how can i thow or handle this.
and what is the type of this execption like,memory,File etc.
First-chance exception at 0x0126a8a4 in test.exe: 0xC0000005: Access violation reading location 0xfeeefeee.
Unhandled exception at 0x0126a8a4 in test.exe: 0xC0000005: Access violation reading location 0xfeeefeee.
please help me for this.
|
|
|
|
|
Hi,
Le@rner wrote: First-chance exception at 0x0126a8a4 in test.exe: 0xC0000005: Access violation reading location 0xfeeefeee
Your code loaded at 0x0126a8a4 attempts to read memory through an unitialized pointer.
When it happens, use the call stack in your debugger to find your faulty code and fix it
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
in diffrent condition exception is occur call stack of all condition mentioned here
condition 1:
wininet.dll!761cf6ea()
[Frames below may be incorrect and/or missing, no symbols loaded for wininet.dll]
wininet.dll!7620ecc0()
wininet.dll!761c9986()
wininet.dll!761df27b()
wininet.dll!761df0f1()
wininet.dll!761c57b3()
wininet.dll!761c5c59()
wininet.dll!761df4c3()
> Test.exe!CAmHttpSocket::OpenUrl(const char * url=0x23b38df0) Line 225 + 0x17 bytes C++
Test.exe!CAmHttpSocket::GetHeaders(const char * url=0x23b38df0) Line 187 C++
Test.exe!CHttp_Mon_Thread::HTTPResponseThread() Line 58 + 0xe bytes C++
Test.exe!CHttp_Mon_Thread::OnTimer(unsigned int idEvent=15901, long dwTime=10345141) Line 140 + 0x7 bytes C++
Test.exe!CWinThread::DispatchThreadMessageEx(tagMSG * pMsg=0x37f106c0) Line 771 C++
Test.exe!AfxInternalPreTranslateMessage(tagMSG * pMsg=0x37f106c0) Line 227 + 0xd bytes C++
Test.exe!CWinThread::PreTranslateMessage(tagMSG * pMsg=0x37f106c0) Line 777 + 0x8 bytes C++
Test.exe!AfxPreTranslateMessage(tagMSG * pMsg=0x37f106c0) Line 255 C++
Test.exe!AfxInternalPumpMessage() Line 178 + 0xf bytes C++
Test.exe!CWinThread::Run() Line 629 + 0x7 bytes C++
Test.exe!_AfxThreadEntry(void * pParam=0x0017f00c) Line 126 C++
Test.exe!_callthreadstartex() Line 348 + 0x6 bytes C
Test.exe!_threadstartex(void * ptd=0x23adbb70) Line 326 + 0x5 bytes C
kernel32.dll!7662eccb()
ntdll.dll!778dd24d()
ntdll.dll!778dd45f()
condition 2:
> Test.exe!ATL::CStringData::Release() Line 111 + 0x7 bytes C++
Test.exe!ATL::CSimpleStringT<char,0>::operator=(const ATL::CSimpleStringT<char,0> & strSrc="10022*Socket Error") Line 300 C++
Test.exe!CSmtp_Mon_Thread::SmtpResponseThread(ATL::CStringT<char,StrTraitMFC<char,ATL::ChTraitsCRT<char> > > URL_Name="http://exby.org", unsigned int Port=1079503120) Line 141 + 0x16 bytes C++
Test.exe!CSmtp_Mon_Thread::OnSmtpTimer(unsigned int idEvent=17291, long dwTime=10345141) Line 69 C++
Test.exe!CWinThread::DispatchThreadMessageEx(tagMSG * pMsg=0x14e5cd50) Line 771 C++
Test.exe!AfxInternalPreTranslateMessage(tagMSG * pMsg=0x14e5cd50) Line 227 + 0xd bytes C++
Test.exe!CWinThread::PreTranslateMessage(tagMSG * pMsg=0x14e5cd50) Line 777 + 0x8 bytes C++
Test.exe!AfxPreTranslateMessage(tagMSG * pMsg=0x14e5cd50) Line 255 C++
Test.exe!AfxInternalPumpMessage() Line 178 + 0xf bytes C++
Test.exe!CWinThread::Run() Line 629 + 0x7 bytes C++
Test.exe!_AfxThreadEntry(void * pParam=0x003af3a4) Line 126 C++
Test.exe!_callthreadstartex() Line 348 + 0x6 bytes C
Test.exe!_threadstartex(void * ptd=0x21f742d8) Line 326 + 0x5 bytes C
kernel32.dll!7662eccb()
[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
ntdll.dll!778dd24d()
ntdll.dll!778dd45f()
condition 3:
> Test.exe!ATL::CStringData::Release() Line 111 + 0x7 bytes C++
Test.exe!CErrorNotifications::~CErrorNotifications() Line 52 + 0x3e bytes C++
Test.exe!CErrorNotifications::`scalar deleting destructor'() + 0x8 bytes C++
Test.exe!CWinThread::Delete() Line 591 C++
Test.exe!AfxEndThread(unsigned int nExitCode=0, int bDelete=1) Line 381 C++
Test.exe!CErrorNotifications::ErrorNotificationThread() Line 182 C++
Test.exe!CErrorNotifications::InitInstance() Line 59 C++
Test.exe!_AfxThreadEntry(void * pParam=0x4458f9a4) Line 113 + 0x7 bytes C++
Test.exe!_callthreadstartex() Line 348 + 0x6 bytes C
Test.exe!_threadstartex(void * ptd=0x22175248) Line 326 + 0x5 bytes C
kernel32.dll!7662eccb()
[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
ntdll.dll!778dd24d()
ntdll.dll!778dd45f()
now please help me
modified on Wednesday, November 17, 2010 4:31 AM
|
|
|
|
|
Use your debugger to inspect the problem more in detail. Step into the code to inspect the different variables.
|
|
|
|
|
Le@rner wrote: now please help me
Follow your code in the debugger ahead of the place where you generate a socket error with "http://exby.org".
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
its generate using this line
CSMTP smtp;
StatusTh = smtp.get_response();
CString CSMTP::get_response()
{
try
{
char buf[240];
sock_error=WSAGetLastError();
if(sock_error!=0)
{
if(sock_error==10048)
sock_str = "10048*Address already in use";
else if(sock_error==10049)
sock_str = "10049*Cannot assign requested address";
else if(sock_error==10050)
sock_str = "10050*Network is down";
else if(sock_error==10051)
sock_str = "10051*Network is unreachable";
else if(sock_error==10060)
sock_str = "10060*Connection timed out";
else if(sock_error==10064)
sock_str = "10064*Host is down";
else if(sock_error==10061)
sock_str = "10061*Connection refused";
else if(sock_error==10054)
sock_str = "10054*Connection reset by peer";
else
{
sock_str.Format("%d",sock_error);
sock_str = sock_str + "*Socket Error";
}
return sock_str;
}
recv(sock,buf,sizeof(buf),0);
sock_error=WSAGetLastError();
if(sock_error!=0)
{
if(sock_error==10048)
sock_str = "10048*Address already in use";
else if(sock_error==10049)
sock_str = "10049*Cannot assign requested address";
else if(sock_error==10050)
sock_str = "10050*Network is down";
else if(sock_error==10051)
sock_str = "10051*Network is unreachable";
else if(sock_error==10060)
sock_str = "10060*Connection timed out";
else if(sock_error==10064)
sock_str = "10064*Host is down";
else if(sock_error==10061)
sock_str = "10061*Connection refused";
else if(sock_error==10054)
sock_str = "10054*Connection reset by peer";
else
{
sock_str.Format("%d",sock_error);
sock_str = sock_str + "*Socket Error";
}
return sock_str;
}
else
{
CString temp = buf;
return temp;
}
}
catch( CMemoryException* e )
{
e->Delete();
}
catch( CFileException* e )
{
e->Delete();
}
catch( CException* e )
{
e->Delete();
}
}
|
|
|
|
|
You should really learn to use your debugger properly. You can't come post a question on the forum each time your program crashes. The debugger is a very powerfull tool and you should really start to learn how to use it, it can make you gain a lot of time. It's very difficult to help you without being able to use a debugger.
|
|
|
|
|
Le@rner wrote:
else
{
CString temp = buf;
return temp;
}
Your problem is here. Guess why
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
can i use it like this
return buf;
|
|
|
|
|
The problem is that you don't terminate your string when you call recv. See this thread[^] (just below) for more info.
Now, if you would have used your debugger, you would probably have spotted the problem immediately (by inspecting the string which is not terminated).
|
|
|
|
|
No, buf is not null terminated
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
Alain Rist wrote: Your problem is here
Nope, the problem is with the call to recv.
Well, it depends what you meant exactly . This line in itself is not the fault, the problem is that buf is non terminated which could cause serious problems when copying into a CString object.
|
|
|
|
|
He could have constructed his CString with a length
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
please explain me where is the problem and how can i resolve it.
thanks in advance.
|
|
|
|
|
See Cedric's detailed explanations[^].
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
It's been explained to you nearly a half dozen times. What more do you require?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hey I googled for this kinda stuff but only useless stuff came up..
Anyway
char buffer[250];
send(sock, "hello?\n", 8, 0);
recv(sock, buffer, sizeof(buffer), 0);
cout << buffer << endl;
cin.get();
is my code.
Now I obviously do not know how big the buffer will be, the problem is if i set buffer[250], everything after the actual content is trash.
How would I fix that?
Like I wanna see only the actual content and not the jibberish after it.
Thanks.
e// nevermind, I just found out that recv returns the size..
modified on Tuesday, November 16, 2010 7:57 PM
|
|
|
|