|
Hi,
Just started using the boost libraries to do asynch i/o and not sure if this is the best forum for this but will post anyway.
First question I am specifying a delimiter character in the call but when I display what I get back it looks like it is also implicitly returning when a LF \'n' char is reached even though this isn't my delimiter. Could this method have default delimiters that need to be managed? I haven't seen this in the documentation so far.
Secondly, the second argument in the call is a "boost::asio::streambuf b". What's the best way to extract the message from the buffer and put it into an std::string?
I've played around with:
size_t n = b.size();
b.commit(n);
std::istream is(&b);
std::string s;
is >> s;
But now sure what's going on under the covers here.
Any help would be appreciated.
Thanks
ak
|
|
|
|
|
Hi,
I have owner draw button control and setfont to 20. But I am getting font height using GetTextMetrics() but I am not getting 20 anywhere, I am getting 16 each time.
HDC dc= ::GetDC(this->m_hWnd);
TEXTMETRIC tm;
::GetTextMetrics(dc,&tm);
|
|
|
|
|
It would be more useful if you posted the code where you select the font.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
m_font.CreateFont(20,0,0,0,FW_BOLD,0,0,0,0,0,0,0,0,_T("Arial"));
SetFont(&m_font);
|
|
|
|
|
Does this code actually change the font of the button control?
"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
|
|
|
|
|
The value above does not equate to a 20 point font, you must first convert it to device units as described here[^].
Just say 'NO' to evaluated arguments for diadic functions! Ash
modified on Wednesday, November 17, 2010 3:18 PM
|
|
|
|
|
Hi all,
i m using this function
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;
}
int res = recv(sock,buf,sizeof(buf),0);
if (res != SOCKET_ERROR)
{
buf[res] = 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
{
return buf;
}
}
catch ( CInternetException* e )
{
e->Delete();
}
catch( CMemoryException* e )
{
e->Delete();
}
catch( CFileException* e )
{
e->Delete();
}
catch( CException* e )
{
e->Delete();
}
}
where i call this function its generate exception,please tell me what wrong with function.
its callstack is
ntdll.dll!7788ac0f()
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
ntdll.dll!7788a58b()
kernel32.dll!76623f01()
> Test.exe!free(void * pBlock=0x410f28f0) Line 110 C
Test.exe!CMemFile::Free(unsigned char * lpMem=0x410f28f0) Line 118 + 0x8 bytes C++
Test.exe!ATL::CStringData::Release() Line 113 C++
Test.exe!CSMTP::~CSMTP() Line 13 + 0x1c bytes C++
Test.exe!CSmtp_Mon_Thread::SmtpResponseThread(ATL::CStringT<char,StrTraitMFC<char,ATL::ChTraitsCRT<char> > > URL_Name="http://dezsredstva.ru", unsigned int Port=1091512576) Line 227 + 0x13 bytes C++
Test.exe!CSmtp_Mon_Thread::OnSmtpTimer(unsigned int idEvent=22610, long dwTime=11655606) Line 69 C++
Test.exe!CWinThread::DispatchThreadMessageEx(tagMSG * pMsg=0x093e7cf8) Line 771 C++
Test.exe!AfxInternalPreTranslateMessage(tagMSG * pMsg=0x093e7cf8) Line 227 + 0xd bytes C++
Test.exe!CWinThread::PreTranslateMessage(tagMSG * pMsg=0x093e7cf8) Line 777 + 0x8 bytes C++
Test.exe!AfxPreTranslateMessage(tagMSG * pMsg=0x093e7cf8) 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=0x0023f25c) Line 126 C++
Test.exe!_callthreadstartex() Line 348 + 0x6 bytes C
Test.exe!_threadstartex(void * ptd=0x02b2fcd8) Line 326 + 0x5 bytes C
kernel32.dll!7662eccb()
ntdll.dll!778dd24d()
ntdll.dll!778dd45f()
thanks in advance
|
|
|
|
|
The code you showed (CSMTP::get_response ) isn't in the stack you gave!
Steve
|
|
|
|
|
Please, don't repost your question. This is considered rude.
Besides, you have been given advice to use your debugger, did you already tried that ? If you are in a hurry, why don't you try to solve the problem instead of waiting that people give you the complete solution.
We've been giving you everything that you need to fix your problem. It seems you are not really willing to learn as your username would suggest it...
|
|
|
|
|
ok sir
actully i m not find out the exact problem by call stack window.
i dont know how to use it.
so...
|
|
|
|
|
When the crash occurs, you can see the call stack window and double click on lines in the call stack. This will bring you to the line in question. Now, try to locate the crash somewhere in your code and put breakpoints (F9) before the line which crashes. Then you can step into the code and inspect the variables which are causing problems (here it seems it is a CString which seems corrupted). For instance you can verify that the strings are properly formated and valid pointers.
You can't expect doing any serious software development without using a debugger. When there's a crash like that, your first reflex is to first try to see which information you can extract with the debugger. Then, if you still didn't fix your problem and are still stuck, you can come and ask a question by providing the information from the debugger.
|
|
|
|
|
Why are you returning the dead (i.e. out-of scope) variable buf ?
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]
|
|
|
|
|
CPallini wrote: returning the dead
sounds like a horror movie from the "old times", "Return of the dead variable", now in color! You could say it's a coding horror movie.
> 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 <
|
|
|
|
|
Code-o-mat wrote: sounds like a horror movie from the "old times", "Return of the dead variable", now in color! You could say it's a coding horror movie
More like a 'code horror' of the new generations...
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]
|
|
|
|
|
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
|
|
|
|