Bug 2298 - NetworkStream reporting success when it failed.
Summary: NetworkStream reporting success when it failed.
Status: RESOLVED FEATURE
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 5.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2011-12-01 12:15 UTC by Dean Cleaver
Modified: 2014-02-20 21:06 UTC (History)
3 users (show)

Tags:
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:
Status:
RESOLVED FEATURE

Description Dean Cleaver 2011-12-01 12:15:09 UTC
I’m experiencing some unusual network behaviour that I can’t work out. In short, my app communicates with the server either via web services or TCP-IP calls, depending on the process. Some processes have mixed calls.
 
What I am seeing in one case is the web service call works and then it proceeds to make a TCP-IP call, which reports that it worked too – however it didn’t work. The code below returns “true” so I know all checks passed, and no exceptions occurred, but the TCP-IP data never makes it to the server.
 
This can be proven by turning 3G off, and walking outside wireless network range so I have no connectivity at all – is it the iPhone reporting success in sending the message, or MonoTouch? How can I get it to fail like it should?
 
Dino
 
try
{
    if (this.clientStream == null)
    {
        if (this.stopClient)
            return false;
 
        this.Continue(5);
 
        if (this.clientStream == null)
            return false;
    }
 
    if (!this.clientStream.CanWrite)
        return false;
 
    if (message == null)
        return false;
 
    this.clientStream.Write(message, 0, message.Length);
    return true;
}
catch (NullReferenceException)
{
    return false;
}
catch (ObjectDisposedException)
{
    return false;
}
catch (IOException)
{
    return false;
}
catch (Exception ex)
{
    this.SendError(ex, "Error in SendMessage byte[]");
    return false;
}
Comment 1 Gonzalo Paniagua Javier 2012-03-16 16:10:14 UTC
A successful call to Socket.Write does not mean that the data left the device. It means that the kernel accepted it and has it in a buffer that will be sent.