D
David Hearn
I have an app which talks between two PDAs connected by an ad-hoc
wireless network. The underlying communication is performed by a
TcpListener and TcpClient combination, using a NetworkStream to actually
pass the data.
When the PDA goes into sleep mode, the wireless gets disabled. When the
PDA is woken up, the app tries to use the NetworkStream and gets an
IOException: "Unable to write data to the transport connection" (or read
depending on where the error occurred).
I understand that this is because when the WiFi gets dropped, the
underlying socket is destroyed, breaking the NetworkStream.
Are there any accepted design patterns or examples around for this? I
guess I need gracefully to handle the loss of the stream/socket - but I
cannot recreate it until the WiFi is back up, reconnected and a valid IP
address is obtained and the PDA at the other end is in a position to
accept connections again.
Alternatively, is there any way to disable the loss of WiFi when
sleeping (unlikely), or a way of turning off sleep mode whilst the app
is running? The app is a simple proof-of-concept demo and is acceptable
to lose sleep mode.
Thanks
David
wireless network. The underlying communication is performed by a
TcpListener and TcpClient combination, using a NetworkStream to actually
pass the data.
When the PDA goes into sleep mode, the wireless gets disabled. When the
PDA is woken up, the app tries to use the NetworkStream and gets an
IOException: "Unable to write data to the transport connection" (or read
depending on where the error occurred).
I understand that this is because when the WiFi gets dropped, the
underlying socket is destroyed, breaking the NetworkStream.
Are there any accepted design patterns or examples around for this? I
guess I need gracefully to handle the loss of the stream/socket - but I
cannot recreate it until the WiFi is back up, reconnected and a valid IP
address is obtained and the PDA at the other end is in a position to
accept connections again.
Alternatively, is there any way to disable the loss of WiFi when
sleeping (unlikely), or a way of turning off sleep mode whilst the app
is running? The app is a simple proof-of-concept demo and is acceptable
to lose sleep mode.
Thanks
David