|
We have developed one IOCP server Application.
We got a socket close event when client application (safe/unsafe) close.
But when client machine restarts or network cable unplugged we can not get
any event of the socket close.
We have also tried to set socket timeout with setsockopt() ,but its not working with IOCP.
So ,Is there any method to get close event for this sockets? or any other method to set
timeout in IOCP.
Thank you.
|
|
|
|
|
What is an "IOCP server Application"?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
No, IP is not a 'connected' protocol, it just maintains connection state on each side. This is usually considered a feature as it allows recovery from temporary disconnects.
A common solution is to add a heart-beat message to your protocol that the server sends to the client. The heart-beat message basically says 'hey, are your still there? if so please respond to this'. If the client doesn't respond in a timely manner it is assumed that the connection is broken.
See: http://tangentsoft.net/wskfaq/newbie.html#abnormalclose[^]
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
Hi to all.
I have an app which opens Personal Address Book using MAPI. I display info about contacts.
My problem is that I can't get to display business fax number, other properties like display_name is properly shown but fax not. I use virtual CListCtrl to display info, my code is as follows:
after all needed calls to Initialize,Logon,Getting PAB and so on..
LPSPropValue lpDN = PpropFindProp(lpRows->aRow[0].lpProps,lpRows->aRow[0].cValues,PR_BUSINESS_FAX_NUMBER);
lpDN != NULL ? l_strText = lpDN->Value.lpszA : l_strText="";
if(!lpDN)
{
lpDN = PpropFindProp(lpRows->aRow[0].lpProps,lpRows->aRow[0].cValues,PR_BUSINESS_FAX_NUMBER_W);
lpDN != NULL ? l_strText = lpDN->Value.lpszW : l_strText="";
}
if(!lpDN)
{
lpDN = PpropFindProp(lpRows->aRow[0].lpProps,lpRows->aRow[0].cValues,PR_BUSINESS_FAX_NUMBER_A);
lpDN != NULL ? l_strText = lpDN->Value.lpszA : l_strText="";
}
in all this cases my lpDN is NULL!
Why is this happening?
I know my contact has business fax number!
|
|
|
|
|
I'm wondering why nobody replied to my question is it not clear of what?
I would be more than grateful for a suggestion of any kind. I could share more info on this if someone is interested.
This problem is annoying me for days so please help.
Thanks.
|
|
|
|
|
Like virtual memory, when read/write the memory,
if the page is in the memory, there will be little extra overhead .
And if the page is not in the memory, the program will deal with the page fault,
and jump back to re-run the operation that generate the page fault.
Now I'd like to apply this to cache implementation,
I suppose the cache always contains what should be cached.
So if the data is in the cache, it'll run smoothly.
If not, it can jump to prepare the cache and jump back to re-run.
PS: I need this because the cache in my application is the intermediate calculation result,
and it'll be saved in the database for future use (in other words,
it need to be cached only once, so the program runs as smoothly as possible most of the time)
Any good skill to simulate this?
More local variables mean higher cohensive
Less function parameters mean looser coupling
modified on Wednesday, September 24, 2008 10:14 AM
|
|
|
|
|
I m new to VC++ , I have a vc++ mfc application which i want connect with MySQL database.. earlier it dont have any database connectivity. Can anybody guide step by step to connect it to databse. I have installed MySQL 5 on my system n also installed MySQL connector 5.1 .
In my application , added these two lines of code
#include "afxdb.h"
then in a function void OnClickOk()
{
CDatabase db;
int i;
db.OpenEx(_T("Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=kcc_trades; User=kats;Password=db_logon;Option=3;"));
i = db.IsOpen();
}
but it gives the errors
error C2065: 'CDatabase' : undeclared identifier
1>.\ChangeLimitsForm.cpp(574) : error C2146: syntax error : missing ';' before identifier 'db'
1>.\ChangeLimitsForm.cpp(574) : error C2065: 'db' : undeclared identifier
1>.\ChangeLimitsForm.cpp(576) : error C2228: left of '.OpenEx' must have class/struct/union
1> type is ''unknown-type''
1>.\ChangeLimitsForm.cpp(577) : error C2228: left of '.IsOpen' must have class/struct/union
1> type is ''unknown-type''
and if I put the cursor on CDatabse db; then it shows CDatabase as class and cursor on db shows CDatabase db means memeber ...... also db. shows me the list of available function from which I selected OpenEx....... i mean to say that it identifies CDatabase as class then why it is giving error....
Can anybody help me!!!!!!!!!!
Please I m struggling with these from the last one week.......
thanks
|
|
|
|
|
Are you sure that you included afxdb.h in the right source file (i.e. the one the compiler is complaining about the missing declaration)?
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]
|
|
|
|
|
param_joshi wrote: error C2065: 'CDatabase' : undeclared identifier
You must #include "afxdb.h" as Carlo already pointed out.
param_joshi wrote: Please I m struggling with these from the last one week.......
Gladly you at least tried to resolve it instead of posting urgnz queries.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Yes, i have included "afxdb.h" in the same source file at top and then in the same source file i wrote CDatabase db; when I use this object db and put a dot db. it shows me a list of member function which means it is recongnizing the db object and listing all member functions of the class CDatabase.... but when i compile the source file cntrl+f7 then it gives all the errors...
|
|
|
|
|
If afxdb.h is included, there is no way for this error to pop up. Just verify it again - there's a chance that the file is actually not being included? Wrong path specified for the header files?
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
i m again confirming and copy pasting from the same file .
at top
#include "afxdb.h"
#include "StdAfx.h" // internally defined header
then below under a function
void CChangeLimitsForm:: OkClick()
{
CDatabase db;
int i,j;
db.OpenEx(_T("Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=kcc_trades; User=kats;Password=db_logon;Option=3;"));
i = db.IsOpen();
...
;
;
;
}
and compling this file with cntrl+f7... it gives these errors
error C2065: 'CDatabase' : undeclared identifier
1>.\ChangeLimitsForm.cpp(574) : error C2146: syntax error : missing ';' before identifier 'db'
1>.\ChangeLimitsForm.cpp(574) : error C2065: 'db' : undeclared identifier
1>.\ChangeLimitsForm.cpp(576) : error C2228: left of '.OpenEx' must have class/struct/union
1> type is ''unknown-type''
1>.\ChangeLimitsForm.cpp(577) : error C2228: left of '.IsOpen' must have class/struct/union
1> type is ''unknown-type''
Also is there any other place where we specify path for headers... my header is already in the same source file .. as wrote above.
|
|
|
|
|
param_joshi wrote: #include "afxdb.h"
#include "StdAfx.h"
A rule is that, you MUST include the pre-compiled header before anything else. Change it like
#include "stdafx.h"
#include "afxdb.h" and it should compile just fine. Any code, or anything before the line #include "stdafx.h" will not be compiled at all. You can type any random junk like 'AL;DSFKL;AS;LDFKL;ASD before the precompiled header inclusion to make sure that that the compiler doesn't care about it.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Yes , it got complied......thanks a lot and a lot...... now i could move further..
|
|
|
|
|
I am glad I was of help.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
yes dear... I looked ur profile ..you have a cute n nice n charming baby!! God bless her
|
|
|
|
|
|
Hi
I would like get LoginNames of all users in My Domain.
I could get the list of all user names in my domain using IADS and IDirectorySearch using the article
[^]
Can any body suggest me relevant approach or provide me any links for solving this?
Thanks
Satya
Today is a gift, that's why it is called the present.
|
|
|
|
|
Have you tried NetUserEnum() or NetQueryDisplayInformation() ?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
|
Should I need to delete the thread pointer here
void starttherad()
{
th=AfxBeginThread (StartThread, _param)
}
void stopthread()
{
delete th; // Should I need to delete ?
}
|
|
|
|
|
ptr_Electron wrote: void stopthread()
{
delete th; // Should I need to delete ?
}
No.
Regards,
Sandip.
|
|
|
|
|
Nope. By default the CWinThread m_bAutoDelete data member is TRUE , and the pointer is deleted when the thread terminates (see [^]).
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,
initialize the "m_bAutoDelete" data member for your needs.
If you set this member to TRUE, you doesn't need delete the pointer.
Greetings
|
|
|
|
|
As the others already have said: no, you don't.
At least not in the context you provided.
But...
It's considered good practice to make sure all threads have finished before closing an application. By waiting on the thread handle you make sure the thread has finished. To be able to wait on the thread handle with e.g. ::WaitForSingleObject() , the thread handle must be valid. If the CWinThread object has its m_bAutoDelete member set to TRUE the thread handle will be closed when the thread exit its controlling function and the CWinThread object is destroyed.
If you want to avoid this situation you should create the thread suspended and set the m_bAutoDelete memeber to FALSE before resuming thread execution with a call to CWinThread::ResumeThread().
In this case you have to delete the CWinThread object yourself by calling delete after you've waited on the thread handle CWinThread::m_hThread .
Read more here[^].
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|