[Mono-list] System.Net.TcpClient and IIS6?

Gonzalo Paniagua Javier reply.to.the.list.iam.suscribed@notexists.ximian.com
Wed, 08 Dec 2004 20:09:42 -0500


On Wed, 2004-12-08 at 14:05 +0000, rus wrote:
> Hi all
> 
> I've been doing a little experiment with TcpClient (my first time ;))
> and seem to have stumbled across a difference between mono and ms.NET
> when talking to IIS6 servers.
> 
> I've attached the source below (apologies for bad code - it's just a
> quick experiment to get used to the System.Net stuff)
> 
> If I do..
> mono client.exe www.forgecom.info 80 "/"
> 
> under mono (1.0.4 on FC3), the output cuts out in the middle of the
> response (not sure of the exact position (though it seems consistent).
> 
> under .NET (1.1 on windows 2000), the output is complete.  I've not
> tested it using mono on win32, by the way.
> 
> I've compiled the source using the command:
> mcs -t:exe -out:client.exe TcpClient.cs
> under mono (1.0.4 on FC3) and run the same resulting exe on both
> systems.
> 
> >From my tests so far, mono only seems to have a problem when talking to
> IIS6. IIS5 and apache seem ok!
> 
> Is this a bug or am I missing something?

The problem is in your test code:
do {
       bufferSize = client.ReceiveBufferSize;
       readBytes = new byte[bufferSize];
       net.Read(readBytes, 0, bufferSize);
       result += Encoding.ASCII.GetString(readBytes);
} while(net.DataAvailable);

The condition 'net.DataAvailable' might be false at a certain point. Ie,
there might not be data to read but it will be there soon.

You better use Read (or may be Poll/Read).

-Gonzalo