Bug 5182 - No Exception thrown sending data over network stream when wifi turned off
Summary: No Exception thrown sending data over network stream when wifi turned off
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler ()
Version: 4.2.x
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2012-05-18 17:28 UTC by kenneth.beasley
Modified: 2012-05-19 00:07 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description kenneth.beasley 2012-05-18 17:28:03 UTC

I successfully send data over a network stream after connecting the socket to a specified IP address.  However, when turning off the WiFi (after having established the connection), the network stream sends data over the socket without any indication that the connection has been severed.  Normally, an exception is thrown under such circumstances.

Steps to Reproduce:

With the WiFi connection on, setup a network stream with a socket that is connected to a host on an ip address that is listening on the specified port.  Sending data using the Stream's BeginWrite() method should work at this point.  

Now turn off the wireless connection (without closing the socket and creating a new socket) and try sending data using Stream's BeginWrite().

Actual Results:
No error occurs, and the callback specified in BeginWrite() is immediately called, even though, due to the lack of a physical connection, no data was actually sent.

Expected Results:
An IO Exception should have been thrown since the data technically was not sent.

This is how it works when the code was tested on a Windows device.

Platform is Android 2.3 on an LG Optimus3d
Comment 1 Miguel de Icaza [MSFT] 2012-05-19 00:07:40 UTC

The difference is in the way the underlying operating system handles the connection, it is likely that Android does not shit down the interface and keeps the socket alive until TCP/IP gets a timeout.