|
Code-o-mat wrote: 2 hours is a lot of time, you might want to shorten that.
Dangerous: those timers are expected to be consistent on a very wide number of system, and -because of the way TCP works- there is no need to make it shorter.
The keep-alive is sent on a silent socket to let it be not-anymore silent. But the problem is ... why is it silent?
If there are data to let flow, TCP itself recover transmission error and - if that cannot be done - reports to the soket WSAENETRESET/WSAENOTCONN independently on every keep-alive feature.
If there are no data to let flow for long time, considering servers queue, routing tables, switches cam table, firewall caches, ARP table etc. assuming everything still works the same is risky. Better to close the socket, and reopen it again when furtherly needed, and use some "session layer command or data" (the application should define what the y should be) to track the state of the session or re-sync the client and the server.
In other words, the OP had better to implement a more robust application protocol that uses the underlying socket not just to transfer data, but also to exchange some status information about the existence and activity of the client and the server (this can be done more frequently) if he wants to promptly react to an unexpected event.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
That all might be true but he asked how keepalive works (and correct me if i am wrong in what i answered to that), not how he should design his client/server protocol.
I agree that instead of relying on keepalive he should implement his own mechanism for detecting if the other side is gone because that would give him a much better control over the whole thing, but of course, that's just my oppinion. To detect if a long-silent connection is silent because the other side doesn't have anything to say OR because someone poured some coffee over the router would require -as far as i know- some kind of "pinging" and "timeouting", and keepalive does exactly that, so the aproach isn't fundamentally flawed.
For the "shortening of the 2 hours thing", as i understood you can set the timings for sockets individually, i meant that, not fiddlign with the system-wide settings.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
Koma Wang wrote: how to use it ?
Simple - don't.
No one wants to know if a connection is alive. What they want to know is whether the business logic is still functioning. And the only way to do that is to implement something that actually tests the functionality. The more fully it tests it the better. But at a minimum you can assure that the server is at least still responding to a message enough to return a response.
A simple implementation is to send a do nothing request from the client at a configured interval if no other request has been sent in that period.
And do NOT rely on such functionality to get around error checking legitimate requests. A server can go down right in the middle of a legitimate request.
|
|
|
|
|
mysql returns an error, which contains UNICODE string in whole char* error string as following:
Duplicate entry 'MQ91' for key 'UnicodeName'
here 'MQ91' is UNICODE string but can not be recognized.
How to transfer the English/UNICODE mixed error string above in right format,
or how to know the 'MQ91' is UNICODE?
|
|
|
|
|
What do you mean by "transfer"?
If you are using printf or Format or somesuch, you can use %ls for unicode strings, like:
CString msg;
msg.Format("This is a unicode string: %ls", unicode_string);
You can also use WideCharToMultiByte[^] to convert a unicode string to MBCS (or ASCII?).
Does any of this help?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
Can I use SetWindowTheme to set another set of visual style exclusively for my application ?
For example, My system use window7 style. But I want my application to use WindowXP or a custom style.
modified on Sunday, June 5, 2011 1:47 AM
|
|
|
|
|
No. You can't have application specific themes. If you need that sort of functionality, look at custom UI frameworks. The recent versions of MFC have skinned controls, which offer different visual styles (Office 2007, VS2008 etc.) Also third party MFC control vendors like BCGSoft or Codejock offer a lot of skinnable controls.
|
|
|
|
|
Hi, I'm trying to draw a rectangle on the screen with MouseHook, but i can't:
LRESULT CALLBACK MouseProc(int nCode,WPARAM wParam,LPARAM lParam)
{
LPMOUSEHOOKSTRUCT info=(LPMOUSEHOOKSTRUCT) lParam;
static BOOL capturing = 0;
Pen p(Color(255,255,0,0),5);
Graphics g(GetDC(0));
switch(wParam)
{
case WM_LBUTTONDOWN:
capturing = TRUE;
rcCaptured.left = info->pt.x;
rcCaptured.top = info->pt.y;
break;
case WM_LBUTTONUP:
if( capturing )
{
rcCaptured.right = info->pt.x;
rcCaptured.bottom = info->pt.y;
capturing = FALSE;
}
break;
case WM_MOUSEMOVE:
InvalidateRect(GetDesktopWindow(),NULL,FALSE);
g.DrawRectangle(&p,rcCaptured.left,rcCaptured.top,info->pt.x-rcCaptured.left,info->pt.y-rcCaptured.top);
break;
}
}
how can force repaint of the screen? and how remove hook after select a rectangle?
|
|
|
|
|
I'm guessing your InvalidateRect() call is causing a repaint that ends up covering up what you just drawed to the screen.
What is happening with your current code??
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
InvalidateRect doesn't work, the screen is still dirty.
|
|
|
|
|
Yes, you'd have to set the erase background flag to true in the call and call UpdateWindow() to force an immediate paint. That worked on older OSs but on Windows 7 the updates don't happen while you have the mouse button pressed it seems. It does work on the LBUTTONUP message (just tested it).
You may have to double buffer - grab the image for the rect from the screen, draw your rectangle, draw the captured image back to the screen to erase, etc.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Deja Voodoo. It almost feels like I posted an answer[^] to this problem some days back?
Use SetROP2 to rubberband it.
Yes, you can mix GDI and GDI+ together in the same application. You just need to understand how each works to make them complement each other.
|
|
|
|
|
Hi all,
i am creating a html file,and write data in html file line by line with different formatting of color and font.
now i want to encrypt this file,now please tell me how can i do this?
what method use for this?
either encrypt the file or encrypt the string that is have to be written on this file.
and on decryption side how can i recover it in normal readable format.
please help me and guide for this.
if possible please explain me with any example.
thanks in advance.
|
|
|
|
|
|
tell me also some idea for same situation for mac os.
|
|
|
|
|
Google for : Html encryption.
You will find product such as:
http://www.allynova.com/encrypt-web-pro-order.html
I guess that if you want to encrypt HTML page sent over the web, it would be the way to go...
Or also, you could check:
http://www.iwebtool.com/html_encrypter
This is not very secure but since your page as to be displayed anyhow, what is the purpose to encrypt it.
If the reason is for transport, then probably it should be sent over a securized connection.
Philippe Mori
|
|
|
|
|
What is the purpose to encrypt a HTML file ? And why HTML ?
If the purpose is to protect something on the web, then client side protection is very weak.
Philippe Mori
|
|
|
|
|
I have written an application in c# that has a reference to a dll written in c++. I can run the application in debug mode and it works great, but after I build the application, it will not start and gives me the following error, any thoughts on how to resolve this?
http://img9.imageshack.us/img9/1913/sidebysideerror1.jpg
|
|
|
|
|
You need to at least narrow down whether it is the C# application or the C++ DLL.
"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
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
Hi, thanks for the response. The event log indicates it is the c++ dll that is causing the error. What else would you like to know?
|
|
|
|
|
I have seen that error when you mix 64 and 32 bit platforms. The application and the dll need to agree on their "bitness". Check your build parameters for C# to see the platform selected. If it says "Any", that means that, at runtime, it will pick the architecture best for the machine you are running on. If the dll doesn't match that, you will get this error.
|
|
|
|
|
Thank you, I will try that on Monday when I get back to work and reply back with the results.
|
|
|
|
|
|
Sorry, I don't use Visual Studio Express. In Visual Studio 1008 Enterprise it's in the Project Properties, Build tab, Platform Target field. There's a setting for both Debug and for Release. Sorry I can't post a screenshot of the relevant screen.
|
|
|
|
|
After trying many different settings in VS 2008, I downloaded a different version of the helper dll that I was using and this seems to have fixed the issue. Thank you to the two people that replied.
|
|
|
|