Question

I have an app running on a Windows Mobile device that connects to a Telnet server via a socket. While the device is 'alive' all is well. If the device 'sleeps', on wakeup it opens a new port, which confuses the server and my app gets disconnected. The new port open is not part of my app - is it standard behaviour ? How can I stop it happening ?

Suggestions welcome - thanks :-)

Was it helpful?

Solution

Using sockets before and after suspend/resume depends on the power management settings and setup of the device. If it shutsdown the network (WLAN or WWAN) during suspend, you have to close the socket and open a new connection. You can watch for power notifications using the MS power notification message queue. The app will receive the "device has suspended" message first after the device is resumed! As the same, close and open connection after resume, is true for serial comm too, I can provide a C++ sample for the power message queue: http://code.google.com/p/win-mobile-code/source/browse/trunk/KeyWedge/KeyWedge/PowerMsgQueue.cpp Possibly you may want to disable automatic and manual suspend of the device and provide an option to suspend the device from your app. Then you can gracefully close the communication channel. On the server side you will have to setup the socket to close after some time of inactivity. Otherwise you may run out of communication channels. On the client side you should open and close a comm chanel only as long as you need to transfer data.

The above are general suggestions. If you provide some code snippets, we may help more.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top