Power off - detection/handling

P

Peter Huish

On a PPC can I detect that the power off button has been and do I have
enough time to do something like disconnect from a socket?



thanks,

pete
 
G

Guest

You can detect it, but your handler code will likely only happen after wake.
You might have enough time to run 1 or 2 lines of code, but that's a might.
The amount will vary from run to run, so it's not reliable.
 
P

Peter Huish

You can detect it, but your handler code will likely only happen after wake.
You might have enough time to run 1 or 2 lines of code, but that's a might.
The amount will vary from run to run, so it's not reliable.

So this is a similar situation to what occurs if the device powers
itself down.

The application scenario I am trying to exist with is that my
application has a socket connection to another system. After powerdown
that connection is seemingly unusable (there is a socket exception about
trying to use something to that is not a socket). So I would assume
that if I did a socket.close on that same connection I would fail as
well.

Meanwhile, the server application seems to think that the connection
still exists so I need to be able to reinstate the PPC side's socket
comms or clean up on the server side.

I deal with the PPC turning itself off by using a timer that I reset
whenever there is activity and if there is no activity I do a socket
close and reconnect when there is a requirement for more activity. This
needs to be improved some as I need to determine that there is in fact a
wireless connection before doing the reconnect but that is another
problem.

Is the situation where my socket becomes unusable after a
powerdown/powerup the normal situation or am I missing something?

As a supplementary question related to powerdown. If I run my
application simulating the network traffic via a timer (for load
testing) it seems that the powerdown due to the device not being used
occurs. What defines 'not being used'?


thanks
 
G

Guest

The socket being invalid is normal behavior as when you power down, the
ethernet controller shuts off. When you power up it reinitializes and
negotiates with the network. It doesn't know if you've been off for a
second or a year and it can't assume that when it comes back up it's going
to be in the same network topology.

Have you tried to call Close after power down and back up? It might still
work to close the handles.

"Used" is defined by the OEM. If their network driver calls
SystemIdleTimerReset (which most do so it doesn't power down during file
streaming or large downloads) then the system won't go into suspend mode.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top