[Mono-devel-list] NetworkStream

Martin Hinks mhinks at gmail.com
Wed Jul 20 04:58:53 EDT 2005

Hi Arnhoffer,

There are various things to try:

1.) Check that tIntFullSize is not 0 when the .Read line is called.
2.) Try this with a plain networkstream derived from a socket rather
than from a TcpClient
3.) If you are trying to read the entire buffer of length
tintFullSize, is it not possible that the server has not sent all the
data when the read is performed? ie. Just because DataAvailable is
true does NOT mean that you may be able to read ALL the data you are
expecting from the stream, it might not have arrived yet, and as you
are expecting to be able to read it all it might return 0 (I think it
should block though, which is why it must work on .NET)
4.) After some of the diagnoses above, file a bugzilla report.


On 7/20/05, Arnhoffer Károly <karnhoffer at ecron.hu> wrote:
> Hi,
> I have a server service created by Visual Studio .Net. It is using System.Net.Sockets.TcpClient.GetStream to get a stream to communicate on the network. When I run this service on a Windows machine (MS .NET framework) everything is fine, but when running on a Linux machine (SuSE 9.2, Mono 1.1.8 (from RPMs)) the service reads allways zeroes from the stream.
> Example:
>         Private Function ReadData(ByRef tobjNetStream As NetworkStream, ByRef tbytBuffer As Byte(), ByVal tintFullSize As Integer) As Boolean
>                 Dim lintSize As Integer = 0
>                 Dim llogReadEverything As Boolean
>                 Dim lintCounter As Integer
>                 ReDim tbytBuffer(tintFullSize - 1)
>                 While Not llogReadEverything
>                         While Not tobjNetStream.DataAvailable
>                                 Thread.CurrentThread.Sleep(50)
>                         End While
>                         lintSize += tobjNetStream.Read(tbytBuffer, 0, tintFullSize)
>                         If lintSize >= tintFullSize Then
>                                 llogReadEverything = True
>                         End If
>                 End While
>                 Return True
>         End Function
> A function like this gets zeroes from the stream when nonzero data was sent.
> Thanks!
> Arnhoffer Károly
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list

Martin Hinks

More information about the Mono-devel-list mailing list