What event does application call when it is ended abnormally?

I use MFC Visual C++ 4.2. 

I need to know what event / function will be called by the application in 
case of they ended unexpectedly due to errors / power supply problem, etc? 

I will need this to decide the end of server-client connection in case one 
of them experiencing error and must be ended abnormally.

Thank you.
0
landon (165)
12/18/2008 7:28:01 AM
vc.mfc 33608 articles. 0 followers. Follow

22 Replies
1514 Views

Similar Articles

[PageSpeed] 2

>I need to know what event / function will be called by the application in 
>case of they ended unexpectedly due to errors / power supply problem, etc? 

Sounds like you're looking for WM_LOWVOLTAGEDETECTED ;)

If your hardware is dead, so is your software :)

>I will need this to decide the end of server-client connection in case one 
>of them experiencing error and must be ended abnormally.

That sounds like you need to just check that your inter machine
communication mechanism has disappeared - but without knowing what
that mechanism is, no one will be able to help you.

Dave
0
davidl7375 (2060)
12/18/2008 8:31:07 AM
"Landon" <Landon@discussions.microsoft.com> wrote in message 
news:0A7839D0-49D7-47D1-830B-683953286594@microsoft.com...
>I use MFC Visual C++ 4.2.
>
> I need to know what event / function will be called by the application in
> case of they ended unexpectedly due to errors / power supply problem, etc?
>
> I will need this to decide the end of server-client connection in case one
> of them experiencing error and must be ended abnormally.

Man... VC 4.2. Those were the days I tell ya. I LOVED that compiler! Starts 
up about as slowly as notepad. Help is instant and integrated into the 
MDI... everything simple and fast (!!!!!!!NO COM!!!!!!!). You. are. *the*. 
man!

And you're not alone btw (no matter what anyone says). I know many people 
who are still using 4.2, and they all still love it.

Somewhere we (mankind that is) got lost... and every piece of code has to 
sit on a webpage or someone's electric shaver or game console, and then play 
music videos and have a google toolbar sitting there amongst the inevitable 
moutain of bogus "ninternetey clutter" (plus ads of course! can't forget the 
ads). Ahh the good ol days...

Sorry, no idea about your question. I'm just being nostalgic... ;)

- Alan Carre


0
alan314 (63)
12/18/2008 11:36:09 AM
What you will have to do is build a ping mechanism in your client server 
application.

For example, every 2 minutes send a ping message from your clients to the 
server, and meanwhile the server goes through the connections and if one 
hasn't pinged in a while then it disconnects it.

What I have done in the past is to put a time/date in my connection class on 
the server side, every time the server receives a message from the client I 
would store the time that it came, no matter what the message was.  Then 
when the system was idle I would loop through the connections and if the 
last message was not within the last X minutes, I would disconnect the 
connection.

Now on the client side, I had a timer for X minutes, and every time a 
message was sent to the server, I would reset the timer.  And when the timer 
would hit I would send a ping message to keep the connection alive.


AliR.



"Landon" <Landon@discussions.microsoft.com> wrote in message 
news:0A7839D0-49D7-47D1-830B-683953286594@microsoft.com...
>I use MFC Visual C++ 4.2.
>
> I need to know what event / function will be called by the application in
> case of they ended unexpectedly due to errors / power supply problem, etc?
>
> I will need this to decide the end of server-client connection in case one
> of them experiencing error and must be ended abnormally.
>
> Thank you. 


0
AliR3470 (3235)
12/18/2008 4:26:45 PM
But Alir, I cannot use timer. It will slow down and become a burden to all 
clients so does the server. I am thinking how if on the client side can also 
LISTENING to the server existence. LISTENING does not need a timer, does it? 
Is it possible?

Thank you.
0
landon (165)
12/18/2008 11:52:12 PM
"Landon" <Landon@discussions.microsoft.com> wrote:
> I need to know what event / function will be called by the application in
> case of they ended unexpectedly due to errors / power supply problem, etc?
>
> I will need this to decide the end of server-client connection in case one
> of them experiencing error and must be ended abnormally.

You could try using a simple exit code, but more likely you will need to
implement your own error code. Just look at the kind of packets that can be sent
and create a new kind that indicates an error. Of course it�s all moot if the
connection goes down.


-- 
Alec S.
news/alec->synetech/cjb/net


0
Alec
12/19/2008 1:14:46 AM
What I am confusing is when  do I should send the packet? If both 
Server/Client ended normally, of course it's OK whatever the packet is I just 
read and translate it. But if the machine got down before sending that 
packet, what packet I should read? The packet should be nothing, right? 

I am sorry I still don't get it about this one. 

What solution should I do? 

Thank you.
0
landon (165)
12/19/2008 1:45:02 AM
"Landon" <Landon@discussions.microsoft.com> wrote in message
news:0A003FFA-FD6B-450A-9879-C31F71D6FA86@microsoft.com...
> What I am confusing is when  do I should send the packet? If both
> Server/Client ended normally, of course it's OK whatever the packet is I just
> read and translate it. But if the machine got down before sending that
> packet, what packet I should read? The packet should be nothing, right?
>
> I am sorry I still don't get it about this one.

If the connection is severed, then there�s not much you can do. The only real
solution in that case is the ping one that was suggested by AliR.

One thing you could try is to determine some kind of practical timeout. That is,
assume that if you have not had a packet in a while (some length of time that is
longer than any normal expected period of inactivity), send a packet to check if
the other machine is still alive. That way you are effectively doing the
ping-thing, but not constantly, only when you suspect the other machine may be
gone, thus relieving the burden that you were concerned about.


-- 
Alec S.
news/alec->synetech/cjb/net


0
Alec
12/19/2008 2:09:26 AM
Alec, now I have tried to make all clients LISTENING to the server existence 
and according to my mind it should have worked but I've got one big problem:

When Server has error, it needs to be restarted, after that all clients need 
not to restart their applications because I have make them ALSO listening 
like the server does. But when came to this condition, I got both Server and 
Client WAITING each other to send a NOTIFICATION packet. 

Problem on Server side: How can Server get all clients that it need to send 
them the NOTIFICATION packet since there HASN'T been any clients connecting 
since the Server app Restarted?  

Problem on Client side: It is now Listening to check if the Server is exist 
or not. The problem is when can clients know if the Server has been ON / 
ACTIVE again if the Server have not been able to SEND NOTIFICATION packet to 
its clients?

Do you have any idea to solve this problem? 

Thank you.
0
landon (165)
12/19/2008 8:36:01 AM
You will have to use a timer, there is no other way around it.  Why would a 
timer that hits every 2 minutes slow down the system?

As far as the client side listening to a server, that will also need a 
timer.  But what good would that do on your connections on the server. I 
thought the point of this was to eliminate dead connection threads on the 
server side.

AliR.


"Landon" <Landon@discussions.microsoft.com> wrote in message 
news:9318B52C-98BF-4120-BA4E-E3A10F3CFE4C@microsoft.com...
> But Alir, I cannot use timer. It will slow down and become a burden to all
> clients so does the server. I am thinking how if on the client side can 
> also
> LISTENING to the server existence. LISTENING does not need a timer, does 
> it?
> Is it possible?
>
> Thank you. 


0
AliR3470 (3235)
12/19/2008 3:50:14 PM
"Landon" <Landon@discussions.microsoft.com> wrote:
> Problem on Server side: How can Server get all clients that it need to send
> them the NOTIFICATION packet since there HASN'T been any clients connecting
> since the Server app Restarted?

Can you have the server do some sort of broadcast? All clients who are now
listening would detect the broadcast notification and know that the server has
just restarted.


> Problem on Client side: It is now Listening to check if the Server is exist
> or not. The problem is when can clients know if the Server has been ON /
> ACTIVE again if the Server have not been able to SEND NOTIFICATION packet to
> its clients?

If the client has not had any packets from the server in a while (especially if
it is a packet that should have come because the client asked for something),
then it sends a packet to the server to ask if it is still there. If it gets no
response, the client assumes that the server is currently unavailable and does
whatever it should do when it can�t connect.


-- 
Alec S.
news/alec->synetech/cjb/net



> Alec, now I have tried to make all clients LISTENING to the server existence
> and according to my mind it should have worked but I've got one big problem:
>
> When Server has error, it needs to be restarted, after that all clients need
> not to restart their applications because I have make them ALSO listening
> like the server does. But when came to this condition, I got both Server and
> Client WAITING each other to send a NOTIFICATION packet.
>
> Do you have any idea to solve this problem?


0
Alec
12/19/2008 4:20:45 PM
Power supply problems?  Like, the input power to the computer failed?

If the computer isn't running, it makes it challenging to execute code that responds to
this condition.  

If you want to know if the UPS has detected a failure, the WM_POWERBROADCAST message is
probably your best choice, go read about it.  This assumes that your UPS support software
will issue this message.

"Due to errors" is a much more difficult problem.  What kind of errors?  There are very
few errors that will allow you to intercept them, and even fewer that would make it
possible to recover to the point of doing graceful shutdown, and none that would guarantee
that any attempt to perform a "graceful shutdown" would not generate additional errors.

Most of us deal with this by handling the OnDisconnect event of the socket.
					joe

On Wed, 17 Dec 2008 23:28:01 -0800, Landon <Landon@discussions.microsoft.com> wrote:

>I use MFC Visual C++ 4.2. 
>
>I need to know what event / function will be called by the application in 
>case of they ended unexpectedly due to errors / power supply problem, etc? 
>
>I will need this to decide the end of server-client connection in case one 
>of them experiencing error and must be ended abnormally.
>
>Thank you.
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15972)
12/19/2008 5:59:36 PM
What will slow down?  What do you plan to do when the timer fires, compute the first
billion prime numbers?

Consider OnDisconnect as your notification that the other side has failed.
				joe

On Thu, 18 Dec 2008 15:52:12 -0800, Landon <Landon@discussions.microsoft.com> wrote:

>But Alir, I cannot use timer. It will slow down and become a burden to all 
>clients so does the server. I am thinking how if on the client side can also 
>LISTENING to the server existence. LISTENING does not need a timer, does it? 
>Is it possible?
>
>Thank you.
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15972)
12/19/2008 6:00:50 PM
See below...
On Fri, 19 Dec 2008 00:36:01 -0800, Landon <Landon@discussions.microsoft.com> wrote:

>Alec, now I have tried to make all clients LISTENING to the server existence 
>and according to my mind it should have worked but I've got one big problem:
>
>When Server has error, it needs to be restarted, after that all clients need 
>not to restart their applications because I have make them ALSO listening 
>like the server does. But when came to this condition, I got both Server and 
>Client WAITING each other to send a NOTIFICATION packet. 
***
Also listening to what?  A client would not do a Listen() call because a client is not
going to be able to accept connections and a server will not be able to establish them.

Have you handled OnDisconnect?
****
>
>Problem on Server side: How can Server get all clients that it need to send 
>them the NOTIFICATION packet since there HASN'T been any clients connecting 
>since the Server app Restarted?  
****
It can't, and even if it could, it can't do anything about it, for reasons I already
explained.  It cannot know where the clients are!  It is not valid to assume that if you
have an IP address of the client that you can connect to that IP address.  Therefore,
there is no conceivable way that the server could ever establish connectivity to the
clients in any general environment.  It is the responsibility of the clients to handle the
disconnect notification, then react appropriately.  This could involve attempts to
reconnect, or a simple notification to the user that a reconnection will be required and
wait for the user to reconnect.  One program I have (client program) will detect a
disconnect or a failure to connect at all, and will, over a period of time, try 5 seconds,
10 seconds, 20 seconds, 40 seconds, 80 seconds, etc. later to see if it is back up, until
I dismiss the retrying-connection dialog.  Another generates random numbers on an
ever-increasing interval and keeps retrying until I click the "cancel reconnection
attempts" button, but the app stays up and active (I can still use it to create
information, but it can't upload the information).

You are trying to create impossible solutions to a problem that is well-understood.
*****
>
>Problem on Client side: It is now Listening to check if the Server is exist 
>or not. The problem is when can clients know if the Server has been ON / 
>ACTIVE again if the Server have not been able to SEND NOTIFICATION packet to 
>its clients?
****
Stop right there.  THERE IS NO WAY TO DO THIS!  There is no way the server can notify the
client.  Depending on a nonexistent mechanism to solve your problem will not produce a
reasonable solution.

Note that my client is 192.168.168.4.  That is the IP address you need to connect to it.
But it's an 192.168 address, which means that it is a local IP address, and no router will
send to it.  While it is talking to the network, it goes through my concentrator/firewall,
which assigns it a NAT (Network Address Translation) IP, which exists for that connection
and that connection only.  So if the client saw only what my firewall sent, it would have
only a transient IP address; as soon as the connection fails, the transient address is
gone.  But in fact, my network ISP (Verizon FIOS) assigns me a temporary IP once a day, so
there are two levels of NAT going on.  And those are just the two I know about.

So there is no possible way you can reconnect to my machine after the server reboots,
because there is no path from your server to <192.168.168.4, port, tcp> for any possible
port number I've established.  And the IP address you had is now nonsense.

So forget about the ability to notify clients.  It might work with two machines in your
office while you are testing, but it does not scale up to the real Internet.

The way the client determines the server is up is if a connection succeeds.

Note that servers have to exist behind static IP addresses.  Clients do not necessarily
have static IP addresses.
****
>
>Do you have any idea to solve this problem? 
****
By not trying to create a solution that violates fundamental limitations of the network
architecture.  By having your clients attempt to reconnect based on a timer.
				joe
****
>
>Thank you.
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15972)
12/19/2008 6:16:18 PM
On Fri, 19 Dec 2008 00:36:01 -0800, Landon
<Landon@discussions.microsoft.com> wrote:

>Alec, now I have tried to make all clients LISTENING to the server existence 
>and according to my mind it should have worked but I've got one big problem:
>
>When Server has error, it needs to be restarted, after that all clients need 
>not to restart their applications because I have make them ALSO listening 
>like the server does. But when came to this condition, I got both Server and 
>Client WAITING each other to send a NOTIFICATION packet. 
>
>Problem on Server side: How can Server get all clients that it need to send 
>them the NOTIFICATION packet since there HASN'T been any clients connecting 
>since the Server app Restarted?  
>
>Problem on Client side: It is now Listening to check if the Server is exist 
>or not. The problem is when can clients know if the Server has been ON / 
>ACTIVE again if the Server have not been able to SEND NOTIFICATION packet to 
>its clients?
>
>Do you have any idea to solve this problem? 
>
>Thank you.

Clients do not LISTEN, servers do. Clients CONNECT to servers that LISTEN.
Your server should establish a server port with Listen. Clients initiate a
session with Connect/OnConnect. Servers act on connections with
OnAccept/Accept.

The TCP/IP state machine will take care of the "abnormal" termination
event. If either client or server "vanish" TCP will time out and close the
connection. If either client or server have closed their side and the
partner attempts to send data, TCP will send frames informing the partner
that the host has closed that connection or that there is no session
between them.

The only event you need to detect a broken client/server connection is
OnClose. You can _and_should_ examine the return codes of all the socket
functions for error conditions and respond accordingly.

In the case of OnClose, the error code is WSAECONNRESET if the host on the
other end is still alive but has closed the connection. The error code is
WSAECONNABORTED if the TCP/IP stack has given up on the connection because
the other host has not responded appropriately.

Think of a server as grandma, waiting by the phone for a call. Clients,
(grandchildren) pick up the phone but the parents, (TCP/IP) dial the call
for them and establish the connection. The grandchildren and grandma talk.
When it's time to end the call TCP/IP closes the connection and takes the
phone back from the children. The children need not be concerned about how
the call was made. Connection, Transportation and Termination of the call
was handled and guaranteed by the TCP/IP protocol.
0
geoff9744 (73)
12/20/2008 3:08:51 PM
Alec, I have tried your idea of "the server do some sort of broadcast." And I 
also have some suggestion from my friend, he told me to add 1 more 
application as a "Broadcaster application". 

This "Broadcaster application" is powered by Server engine and will act as 
SERVER. 

This "Broadcaster application" will reside on Client side and will not be 
displayed on screen, so each time Client's application is started, this 
"Broadcaster application" will also ON. It is executed from Client using 
ShellExecute. 

My friend idea was if Server suddenly got an error, somebody will restart it 
and EACH TIME( NO MATTER THE SERVER IS ERROR OR NOT, it will ACT AS Client ) 
then it will CONNECT to"Broadcaster application". After that, "Broadcaster 
application" will notify Client's application by broadcasting message "Server 
ON" to Client's application and connection between Server( the REAL server ) 
and the "Broadcaster application" will be destroyed and Server( the REAL 
server ) will return to act as Server. 

I am a bit confused with this way. What do you think about this idea? 

If I read your idea, is it possible for server to DIRECTLY doing some sort 
of broadcast to all Clients without this "Broadcaster application"?

Thank you very much.
0
landon (165)
12/22/2008 12:33:02 AM
Joe, OnDisconnection handle that you said, it is on the Server side, isn't 
it? I have tried to handle it and also "OnClose event" but when I tried to 
force terminating the Server application from Task Manager, it DID NOT enter 
the OnDisconnect event when I put breakpoints on my code and debugged it, 
neither did the OnClose, I didn't know where does the process gone. 

So does the Clients, I have also handled the events OnClose but when I 
terminated it from Task Manager, the Server did not erasing the client's IP 
from the Cliens list which means that the Server did not know if one of its 
Clients has disconnected from network.

How do you think? And also what do you think about my idea using Broadcaster 
application? 

Thank you very much.


0
landon (165)
12/22/2008 12:36:01 AM
Basically what a broadcast is, is like a person shouting in an area with some
people. Anyone who is interested and cares will listen, everyone else will just
ignore it. What I meant was that the server would send out a message to all
clients on the network when it recovers from a crash like �I�m back!�, and any
clients who use that app would then know that the server is back. Of course I�m
assuming that it�s like an intranet or something; it would not be practical (or
maybe not even possible) to do so across the whole Internet. I suppose the
server could keep a list of clients that were connected, but like Joe said, they
may not be reachable.

Your best bet is to let the server just be a server and put he burden on the
client (where it belongs). The client should be responsible for making sure that
it has a connection to the server.


-- 
Alec S.
news/alec->synetech/cjb/net


"Landon" <Landon@discussions.microsoft.com> wrote in message
news:5241744D-B0DF-453B-8007-7FEC93242F1C@microsoft.com...
> Alec, I have tried your idea of "the server do some sort of broadcast." And I
> also have some suggestion from my friend, he told me to add 1 more
> application as a "Broadcaster application".
>
> This "Broadcaster application" is powered by Server engine and will act as
> SERVER.
>
> This "Broadcaster application" will reside on Client side and will not be
> displayed on screen, so each time Client's application is started, this
> "Broadcaster application" will also ON. It is executed from Client using
> ShellExecute.
>
> My friend idea was if Server suddenly got an error, somebody will restart it
> and EACH TIME( NO MATTER THE SERVER IS ERROR OR NOT, it will ACT AS Client )
> then it will CONNECT to"Broadcaster application". After that, "Broadcaster
> application" will notify Client's application by broadcasting message "Server
> ON" to Client's application and connection between Server( the REAL server )
> and the "Broadcaster application" will be destroyed and Server( the REAL
> server ) will return to act as Server.
>
> I am a bit confused with this way. What do you think about this idea?
>
> If I read your idea, is it possible for server to DIRECTLY doing some sort
> of broadcast to all Clients without this "Broadcaster application"?
>
> Thank you very much.


0
Alec
12/22/2008 1:13:42 AM
Ok I see. Now I am working on it. I still developed the Broadcaster 
application and I tried to send a test message to clients. 

But on Client application I have a problem with compiler error here 

BEGIN_MESSAGE_MAP
     ON_REGISTERED_MESSAGE(WAKEUP, OnWakeUp)	//I've got C2065 here
END_ MESSAGE_MAP

Message registration was done at the CApplication constructor:
static UINT NEAR WAKEUP = RegisterWindowMessage( _T("WAKEUP") );

What was wrong? 

On Broadcaster application there is no problem with compilation.  I just did 
this:
	
       UINT uWakeUpMsg = RegisterWindowMessage( "WAKEUP" );
	DWORD dwRecipients = BSM_APPLICATIONS;
	WPARAM wParam = 0;
	LPARAM lParam = 0;

	BroadcastSystemMessage( 
		BSF_IGNORECURRENTTASK | BSF_NOTIMEOUTIFNOTHUNG,	// do not send message to 
this process
		&dwRecipients,			// broadcast only to applications
		uWakeUpMsg,				// registered private message
		wParam,					// message-specific value
		lParam );				// message-specific value

Thank you.

0
landon (165)
12/22/2008 1:49:01 AM
There is a timeout, which is implementation-defined by the TCP stack, before a
connection-failed notification comes through.

Note that any solution which hints at the possibility that the server will be able to
initiate a connection to the clients by any mechanism whatsoever will be erroneous,
because it can never be implemented.
					joe

On Sun, 21 Dec 2008 16:36:01 -0800, Landon <Landon@discussions.microsoft.com> wrote:

>Joe, OnDisconnection handle that you said, it is on the Server side, isn't 
>it? I have tried to handle it and also "OnClose event" but when I tried to 
>force terminating the Server application from Task Manager, it DID NOT enter 
>the OnDisconnect event when I put breakpoints on my code and debugged it, 
>neither did the OnClose, I didn't know where does the process gone. 
>
>So does the Clients, I have also handled the events OnClose but when I 
>terminated it from Task Manager, the Server did not erasing the client's IP 
>from the Cliens list which means that the Server did not know if one of its 
>Clients has disconnected from network.
>
>How do you think? And also what do you think about my idea using Broadcaster 
>application? 
>
>Thank you very much.
>
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15972)
12/22/2008 3:53:33 AM
"Landon" <Landon@discussions.microsoft.com> wrote in message
news:EA9EBEE6-C72F-4566-88E0-BB72D33A1BBF@microsoft.com...
> But on Client application I have a problem with compiler error here
>
> BEGIN_MESSAGE_MAP
>      ON_REGISTERED_MESSAGE(WAKEUP, OnWakeUp) //I've got C2065 here
> END_ MESSAGE_MAP



WAKEUP is undefined. You should replace it with uWakeUpMsg (the ID of the
registered message).


-- 
Alec S.
news/alec->synetech/cjb/net


0
Alec
12/22/2008 5:32:19 AM
This seems like an overly complex solution to what should be a simple problem.  I've done
a lot of network programming with CAsyncSocket (and if you are using CSocket, you are
doomed anyway, so don't use it) and never had a problem logging the loss of either a
client or a server.

Are you using CSocket or CAsyncSocket?

The server cannot perform outward connections to clients for the reasons I previously
discussed.  
					joe

On Sun, 21 Dec 2008 16:33:02 -0800, Landon <Landon@discussions.microsoft.com> wrote:

>Alec, I have tried your idea of "the server do some sort of broadcast." And I 
>also have some suggestion from my friend, he told me to add 1 more 
>application as a "Broadcaster application". 
>
>This "Broadcaster application" is powered by Server engine and will act as 
>SERVER. 
>
>This "Broadcaster application" will reside on Client side and will not be 
>displayed on screen, so each time Client's application is started, this 
>"Broadcaster application" will also ON. It is executed from Client using 
>ShellExecute. 
>
>My friend idea was if Server suddenly got an error, somebody will restart it 
>and EACH TIME( NO MATTER THE SERVER IS ERROR OR NOT, it will ACT AS Client ) 
>then it will CONNECT to"Broadcaster application". After that, "Broadcaster 
>application" will notify Client's application by broadcasting message "Server 
>ON" to Client's application and connection between Server( the REAL server ) 
>and the "Broadcaster application" will be destroyed and Server( the REAL 
>server ) will return to act as Server. 
>
>I am a bit confused with this way. What do you think about this idea? 
>
>If I read your idea, is it possible for server to DIRECTLY doing some sort 
>of broadcast to all Clients without this "Broadcaster application"?
>
>Thank you very much.
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15972)
12/22/2008 6:53:25 AM
See below...
On Sun, 21 Dec 2008 17:49:01 -0800, Landon <Landon@discussions.microsoft.com> wrote:

>Ok I see. Now I am working on it. I still developed the Broadcaster 
>application and I tried to send a test message to clients. 
>
>But on Client application I have a problem with compiler error here 
>
>BEGIN_MESSAGE_MAP
>     ON_REGISTERED_MESSAGE(WAKEUP, OnWakeUp)	//I've got C2065 here
****
So what the h*** is a C2065.  I'm ABSOLUTELY CERTAIN that error message has text that goes
with it...

I don't see a definition of WAKEUP anywhere; it should be
     ON_REGISTERED_MESSAGE(uWakeupMsg, OnWakeup)

because that's the name of the variable you have that holds the wakup message ID.  It has
to be declared at module-level scope.  

You did not show the prototype of OnWakeup, which can ONLY be
	LRESULT OnWakeUp(WPARAM, LPARAM);

You cannot expect us to diagnose a problem unless you show us the definition of EVERY
variable used in the line that has the error!

Read my essay on message management on my MVP Tips site.  This will be informative, but
overall, it will not actually solve your problem.
*****
>END_ MESSAGE_MAP
>
>Message registration was done at the CApplication constructor:
>static UINT NEAR WAKEUP = RegisterWindowMessage( _T("WAKEUP") );
>
>What was wrong? 
>
>On Broadcaster application there is no problem with compilation.  I just did 
>this:
>	
>       UINT uWakeUpMsg = RegisterWindowMessage( "WAKEUP" );
*****
You declare this as
	static const UINT uWakeUpMsg = ::RegisterWindowMessage(_T("WAKEUP") _T("guid
here"));
it is declared at your module level.
*****
>	DWORD dwRecipients = BSM_APPLICATIONS;
>	WPARAM wParam = 0;
>	LPARAM lParam = 0;
>
>	BroadcastSystemMessage( 
>		BSF_IGNORECURRENTTASK | BSF_NOTIMEOUTIFNOTHUNG,	// do not send message to 
>this process
>		&dwRecipients,			// broadcast only to applications
>		uWakeUpMsg,				// registered private message
>		wParam,					// message-specific value
>		lParam );				// message-specific value
>
****
This is a Really Bad Idea for a huge number of reasons.  First, every time it happens, it
wakes up EVERY application you have, which has to process the message, discover it has no
purpose, and go back to being idle.  This is tremendous overhead.  Second, it should only
be used to broadcast important but infrequent system messages, not user-defined messages.
Fundamentally, the whole idea is bad.  You are solving the problem at the wrong level,
with the wrong mechanisms.

Oh yes, and is this a system service that is doing this?  Then it cannot possibly work,
ever, because you cannot send registered window messages from a system service.
				joe
*****
>Thank you.
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15972)
12/22/2008 7:01:23 AM
Reply:

Similar Artilces:

abnormal program termination
Am experiencing a nagging problem with a windows 98 system running outlook 2000. When outlook is started, the following error immediately shows up: "Microsoft Visual C++ Runtime Library Runtime Error! Office\Outlook.exe Abnormal Program Termination" The only option is to select "ok", after which outlook ends up closing. Logging on as someone else and starting outlook doesn't trigger this problem, it only occurs with one user profile. I've tried reinstalling outlook, however, the same issue happens. One thing i've noticed about the user profile that trig...

Revers DNS PTR for clusters and NLB Front Ends
In situations in exchange clusters and NLB FE servers, the MX records can be pointed to the virtual IP address for email delivery. For outbound email, the smtp ip address is set to the host that is active or the real ip of the front end server. In order for Reverse DNS PTR settings to work for email to say, AOL.COM, do I need to create a total of 3 records for each server. 2 real ips and 1 virtual? How about the MX records? x.x.x.100 - mail.company.com virtual x.x.x.101 - mail1.company.com FE1/cluster node 1 x.x.x.102 - mail2.company.com FE2/cluster node 2 This is ...

OnLoad event criteria
If have the code below in the OnLoad event which is working fine for the most part. The second line is causing a problem for cases where there is no matching record. The code is setting the value - I'd like to have it check the value first, and if it matches the value for the related field in the current form recordset, set the value, otherwise just open the form without setting the value. If CurrentProject.AllForms("AllOpen").IsLoaded Then Me.Combo1 = Forms!AllOpen!ID ' Find the record that matches the control. Dim rs As Object Set rs ...

Printing Private events/appts. on Calendars
A while ago I asked about how to stop Outlook printing private appointments or events in the calendars. Someone said to check "don't print private events" in the print screen which I did. Anyway, the calendar that gets printed, in the day that there is a private event it says "Private Event". How do I stop it from printing them altogether? I want it to appear on the calendar as nothing. ie. if there is only that event then the calendar should appear with no events for that day. Thanks ...

How to fix application errors
Is there something specific you wish to ask? "Apoli" <Apoli@discussions.microsoft.com> wrote in message news:A0ED0789-684E-4216-939A-21F032F2BD00@microsoft.com... > ...

Web Application Very Slow
I've installed CRM 1.2 with the Adventure Works database but the performance of the web application is very slow. What steps should I take to try and improve performance? If I try opening the page http://CRMServer/loader.aspx, it takes approximately 3 minutes in total for it to load. It takes about 20 seconds for "Microsoft Business Solutions CRM" to appear on the title bar, another 1 minute for the left navigation pane to load and 1 1/2 minutes for the remaining items to load. Creating a new activity such as a task or a fax takes just as long. The CRM server is a 2.2GHz P4...

Error in Event Viewer event id 1023 pop3 connector, 1029, 1036, 10
Hello Exchange Administrators, I am getting these Error in Event Viewer "event id 1023 pop3 connector, 1029, 1036, 1015, 1019, 1015" on regular basis after every 15 min for every user. I need yours help to fix these errors. Also tell me why these error are logged in event viewer or cause of these errors We are using WIndoes 2003 SBS, Exchange Server 2003. Thanks you for yours help in advance. On Fri, 1 Sep 2006 11:11:01 -0700, Guri <Guri@discussions.microsoft.com> wrote: >Hello Exchange Administrators, > >I am getting these Error in Event Viewer "event id 1...

deleting events in calender
Version: 2008 Operating System: Mac OS X 10.4 (Tiger) Processor: Intel Email Client: pop I have inadvertently imported a weekly event into my calender. Each event seems to be logged as an individual event rather than a repeat event. I do not know how to delete it. Am trying, unsuccessfully, to show all events in one window so that I can easily select this irrelevant event, but cant display that window. Can you help me, either showing that elusive window, or how to otherwise delete MANY events. In article <59bb30c6.-1@webcrossing.JaKIaxP2ac0>, <leaest@officeformac.com> w...

Catch click event button
Hi all, I was wondering... Is it possible to "catch" a click-event on a BuildIn Offie Button? In order to execute your own VBA-code? e.g. I want to be able to catch the "Undo" button in order to execute a piece of macro code in stead of just "Undoing" only the last action. Greetz, Bert -- Neron It is possible to catch ("intercept") most built-in Word commands, as described at http://www.word.mvps.org/FAQs/MacrosVBA/InterceptSavePrint.htm. In this case, the macro you need to write is named EditUndo, as in Public Sub E...

4117 Event ID Error
Starting 1-29-04 we started getting 4117 error messages just like those discussed in Micrisoft's Knowledge Base Article 190084. The only thing that arcticle suggests is to update to SP 4 which is already installed on the machine. I have never seen this message before and now we are getting one every few minutes. Any help would be appreciated. Thanks Sean Seems like you have something else going on then, check out the following articles and see if these help: 126497 XADM: Limiting the Number of Recipients of a Message http://support.microsoft.com/?id=126497 230250 XFOR: Internet ...

Event
I have recorded a macro that I need to automatically run at 6:45am daily. How do I specify this in the code? Everything you need to know about OnTime procedures (but were afraid to ask): http://www.cpearson.com/excel/ontime.htm You'll need to have excel running for this to work. ===== Some versions of windows have scheduler programs. (Or you can get a freeware/shareware version on the web (www.shareware.com is where I look first.) Then you could have that scheduling program start an excel workbook. If you name the macro Auto_Open, then it'll run when the workbook opens. (But ...

Application.FileSearch in Excel 2007!
Hello, I recently upgraded to 2007 about 8 months ago, and had not run this report I developed since the upgrade and have since googled and found that Application.FileSearch no longer exists. I have been trying to use some of the code snippets to modify my existing code but NOTHING seems to work, can anyone assist in helping me mofidy this code?? Thanks so much in advance. Sub CheckTextFilesForHREFs() Globalindx = 1 'MsgBox "Press OK to begin report" Dim WholeLine As String Dim myPath As String, FilesInPath As String Dim workfile As String Dim myR As Lo...

Event After the sale
Hi to all Is any way to bypass the event that after you complete the sale you get a window with the change in it, in order to go to the next sale you have either hit OK or enter because if you scan an item from that point it does not scan in and it appears to me that you can miss an item from been scanned in any way to fix this issue. Also if you have scan several items into the system and you go to del one item in the middle of the page RMS is loosing its focus and starts to scan into the next line down which deletes the items that have been scanned.I think it should go to the next ...

What event when I click the record selector
I have some labels on the form would like to populate its value (they are calculated values) when I select the record selector, next, previous or last or first. What event should I write the code into? On Tue, 22 May 2007 11:01:23 +1000, "Alan T" <alanpltseNOSPAM@yahoo.com.au> wrote: >I have some labels on the form would like to populate its value (they are >calculated values) when I select the record selector, next, previous or last >or first. > >What event should I write the code into? > Well, don't use Labels for this purpose; use textboxes ...

Recurring event
Is there a way to set a meeting date and have it recurring each month, but not on a certain week or certain date of each month. My meeting happens on a Thursday in each month but not every 2nd, 3rd or 4th Thursday. Some months it is the 3rd Thursday and some it is the 4th Thursday. ...

Events, dear boy, events #3
Aha I pasted: Application.EnableEvents = true into the immediate window and now the code is working. I don't have an code that would have turned it off in the first place, however. Coul this be a default setting somewhere, or is just one of those thing that can happen now and then? Anyway, thanks for the solution, Bo -- Gromi ----------------------------------------------------------------------- Gromit's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=92 View this thread: http://www.excelforum.com/showthread.php?threadid=27721 Just a guess. If you turn...

Posting events to the event viewer.
I've been using a particular method to post program events to the event viewer. It works, but there is an issue that is driving me crazy. Perhaps there is a better way or different way to accomplish what I am doing. 1) My events are listed in a file I call EventLog.mc. The events are in this file using a particular syntax. 2) Right after creating the file for the first time, or if I change the file, I run the event log compiler. by doing "mc.exe EventLog -d". This process creates a file called "EventLog.rc". 3) I directly edit my program's main .rc file. Nea...

Copy toolbars between applications
We are using Office 2003 and I created a toolbar in Excel that I would like to copy to Word. Can this be done and if so, how can the toolbar be copied? Thanks for the help! -- LawTrainer ...

reading win 7 event logs
Thanks in advance for your help. I have an app that reads my xp logs and posts them to a central database using WMI. I understand that has changed in win 7. Can anyone out there steer me in the right direction to read the win 7 logs? Thanks. hi Lance, On 06.05.2010 22:29, Lance McGonigal wrote: > I have an app that reads my xp logs and posts them to a central database > using WMI. > I understand that has changed in win 7. Can anyone out there steer me in > the right direction to read the win 7 logs? Not that I know. Neither WMI http://msdn.microsoft....

Call Event from Subform
I've figured out how to execute a sub on a subform initiated on the form. [Forms]![Contacts]![ContactsAddresses].Form.btnSave_Click I can't for the life of me figure out how to do the opposite. To execute a sub on the form called from the subform. When I do a search it always talks about controls, not subroutines. Can someone please help! On Wed, 10 Feb 2010 17:50:01 -0800, PeterM <PeterM@discussions.microsoft.com> wrote: Me.Parent.myPublicProcedure Note that the procedure must be public. Click events are Private by default, but you can simply...

Event 9582
We are using Exchange 2000 with SP3 on Windows 2000 Server Std. We had to upgrade the memory in the server from 2GB to 4GB for another application. We have the following error every hour in the Application log: Event type: Warning Event source: Microsoft Exchange IS Event category: Performance Event ID: 9582 Description: The virtual memory necessary to run your Exchange server is fragmented in such a way that performance may be affected. It is highly recommended that you restart all Exchange services to correct this issue. These events keep appearing once every hour in my Event viewer log. D...

New Lead Event
Hi, While creating a new lead, i would like to call some third party application which will perform some action. In workflow manager,I can specify rules for the crete new Lead event. Is it possible to define a rule which will call the application on create new lead event. Help Needed. Thanks in advance Regards. Raju Look into the PostURL action in Workflow. Matt Parks MVP - Microsoft CRM ---------------------------------------- ---------------------------------------- On Mon, 13 Sep 2004 12:05:36 +0530, "Raju" <raju@netgalactic.com> wrote: Hi, ...

Front end/Back end Dilema
Hello, I currently have 2 exchange servers. Site 1 is primary about 250 acc'ts Site 2 is the second server about 60 acc'ts. I currently like this setup as if one goes down I have redundancy for mail still being qued then delieved when the other box is backup. My dilema is at Site 1 there server is nearing capacity and the price to do any hardware upgrades is not worth it as I will buy a new one. I've been reading up and it would seem I could benefit from having a front-end exchange box for both these servers to offset OWA access, RPS over HTTPS and mobile SSL access from smart phon...

Help with this Event Procedure
Hi there I currently have this code in my database but I can't seem to make it work (i.e. no new names are added to my combo box). I don't think I have attached the event procedure properyly either. Where should I put it? Private Sub Coach_NotInList(NewData As String, Response As Integer) intAnswer = MsgBox("This coach" & NewData & " is not currently in the list." & vbCrLf & _ "Would you like to add this coach to the list now?" _ , vbQuestion + vbYesNo, "This coach") If intAnswer = vbYes Then str...

How do I recover deleted calendar event? Outlook 2007
I accidentally deleted a recurring event in outlook when syncing with my phone. Have tried looking online but could not find any relevent help. Mik If its not in the deleted items folder, you'll need to restore a backup copy as its deleted for good. -- Diane Poremsky [MVP - Outlook] Outlook Tips: http://www.outlook-tips.net/ Outlook & Exchange Solutions Center: http://www.slipstick.com/ Outlook Tips by email: mailto:dailytips-subscribe-request@lists.outlooktips.net EMO - a weekly newsletter about Outlook and Exchange: mailto:EMO-NEWSLETTER-SUBSCRIBE-REQUEST@PEAC...