|
|
See the CSocket Class[^]. The problems with serialization are described there in the Remarks section.
When using OnReceive() , you can use a timer which is reset in that function. When the timer elapsed, close the connection.
|
|
|
|
|
Thanks for your reply.
In the client side:
I used OnReceive() and a timer variable which is reset to zero in that function. In a separate thread of 1 second frequency, I increment the timer variable to one. So every one second the timer variable is incremented but it is reset to zero in the OnReceive since the data is received in OnReceive() which is sent by the server every second. When the timer variable exceeds 30 counts, it is elapsed. When the timer is elapsed, I closed the client socket using shutdown and deleted the socket.
But When I tested the Server and the client, the server hangs after some 2 hours. Previously my client got hanged or lost connection.
Any suggestion, why the server is getting hanged this time?
|
|
|
|
|
Just to be clear
1. Works in environment A
2. Doesn't work in environment B
Obviously then the environment, not your code, is where the problem originates.
As one possibility there is a firewall rule that is disconnecting/dropping the connection after 2 hours. If that is the problem then the solution is to either fix the rule or alter your application such that it recreates the connection more frequently than the rule disconnects. So say every hour although I might go with less than that. That said though defensive programming would suggest that the connection could be lost, arbitrarily, for any number of reasons so you should be attempting to restore the connection anyways.
FYI might want to verify "crash" versus exit. I worked with one system where it turned out there was some sort of monitor that was externally terminating the application after a certain amount of time. As a windows client app all threads should have a generic global system catch which catches "system" exceptions and logs them. Also normal requests to exit should be logged as well.
|
|
|
|
|
Is there any way to get information about installed anti-virus in system?
|
|
|
|
|
You can look in Control Panel\System and Security
|
|
|
|
|
Thank you but this is manual way.
Can I same using C++ / MFC?
|
|
|
|
|
You can check for a virus scanner under the installed programs in the windows registry in:
HKEY_LOCAL_MACHINEACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall (System wide installs)
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall (User installs)
modified 13-Sep-18 21:01pm.
|
|
|
|
|
There are many keys. Is there any straight way of doing this?
|
|
|
|
|
|
Hello Everybody,
In our application we have added a Ribbon control with multiple tabs.
Is there anyway to select / change tabs through code? I can see an option available in C# (SelectedIndex), like that is there anything available in C++ also?
for eg, I am in 3rd tab in my application, and when I reset, first tab needs to be selected.
Thanks in advance.
Regards,
Gopinath.
|
|
|
|
|
You can set IsSelected to true on the RibbonTab you want to select.
modified 13-Sep-18 21:01pm.
|
|
|
|
|
Hi Thaddeus Jones,
Thanks for your reply.
I don't see any option like isSelected in RibbonControl tabs.
Can you give me a sample code if any, so that I will get some idea.
Regards,
Gopi.
|
|
|
|
|
|
Hi,
Thanks again.
Let me give this a try and let you know.
Regards,
Gopi.
|
|
|
|
|
Your answer is for the .NET Framework, but I think the OP's question is about native C++.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Because of the comparison with the C# version I expected it to be about the same control, but you may be right.
In the CMFCRibbonBar , tabs are called categories and they can be set with SetActiveCategory() .
modified 13-Sep-18 21:01pm.
|
|
|
|
|
I think, this will not work for my solution. Anyways, let me try.
|
|
|
|
|
Hi Richard,
Yes, you are right, its for C++ only.
Regards,
Gopi.
|
|
|
|
|
I have a code as below.
#include <ppltasks.h>
#include <iostream>
using namespace concurrency;
using namespace std;
int wmain()
{
auto t = create_task([]()
{
wcout << L"Task A" << endl;
return create_task([]()
{
wcout << L"Task B" << endl;
});
});
t.then([](task<void>& t3)
{
wcout << L"Task C" << endl;
t3.wait();
}).wait();
}
I expected the output to be
/* Output:
Task A
Task B
Task C
Task B
*/
But the output is
/* Output:
Task A
Task B
Task C
*/
Why t3.wait(); isn't calling the B task again or a tleast should throw error?
Jesus saves
|
|
|
|
|
That's the thing with parallelism, it never does what you expect.
|
|
|
|
|
why is the code giving error while compiling?
task<wstring> my_task()
{
auto s = make_shared<wstring>(L"First value");
return create_task([s] {
wcout << *s << endl;
*s = L"Second value";
return *s;
}).then([s] {
wcout << *s << endl;
*s = L"Third value";
return *s;
});
}
UPDATED
The error is as follows,
Quote: 1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\ppltasks.h(372): error C2338: incorrect parameter type for the callable object in 'then'; consider _ExpectedParameterType or task<_ExpectedParameterType> (see below)
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\ppltasks.h(402): note: see reference to class template instantiation 'Concurrency::details::_FunctionTypeTraits<_Function,_ReturnType>' being compiled
1> with
1> [
1> _Function=my_task::<lambda_fe524192daf67b16ea75ab49971b7103>,
1> _ReturnType=std::wstring
1> ]
1> c:\vc++\concurrency_program\createtask\source.cpp(41): note: see reference to class template instantiation 'Concurrency::details::_ContinuationTypeTraits<my_task::<lambda_fe524192daf67b16ea75ab49971b7103>,_ReturnType>' being compiled
1> with
1> [
1> _ReturnType=std::wstring
1> ]
1>c:\vc++\concurrency_program\createtask\source.cpp(41): error C2440: 'return': cannot convert from 'Concurrency::task<concurrency::details::_badcontinuationparamtype>' to 'Concurrency::task<std::wstring>'
1> c:\vc++\concurrency_program\createtask\source.cpp(41): note: Constructor for class 'Concurrency::task<std::wstring>' is declared 'explicit'
I am just trying to understand ppl programing structure. Where as the following code compiles.
task<wstring> t1 = create_task([]() {
wprintf(L"create_task\n");
return wstring(L"create_task");
});
Jesus saves
modified 12-Jun-18 2:50am.
|
|
|
|
|
Daniel Ramnath wrote: why is the code giving error while compiling? Should we make an attempt at guessing the error?
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Sorry, my description was not elaborate. I updated the error. But I found out the reason and posted it below.
Jesus saves
modified 12-Jun-18 2:56am.
|
|
|
|
|
This issue is solved when 'then' function call is parameterized as follows
task<wstring> my_task()
{
auto s = make_shared<wstring>(L"First value");
return create_task([s] {
wcout << *s << endl;
*s = L"Second value";
return *s;
}).then([](wstring s) {
wcout << s << endl;
s = L"Third value";
return s;
});
}
Jesus saves
modified 12-Jun-18 2:55am.
|
|
|
|