[Mono-list] NetworkStream.ReadByte behavior is differing from ms.net

Francisco Figueiredo Jr. fxjrlists at yahoo.com.br
Tue Sep 5 10:10:52 EDT 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1



Hi all,

While playing with NetworkStream.ReadByte in Npgsql I faced a situation
where Mono behavior is differing from ms.net.

If I establish a connection and later stop server while client is
connected and call NetworkStream.ReadByte() from client, ms.net throws a
SocketException wrapped inside an IOException, while Mono returns -1.

This is ms.net stack trace:

Unhandled Exception: System.IO.IOException: Unable to read data from the
transp
rt connection. ---> System.Net.Sockets.SocketException: Uma conexão
estabelecid
 foi anulada pelo software no computador host
   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset,
Int32 size
 SocketFlags socketFlags)
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset,
Int32
ize)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset,
Int32
ize)
   at System.IO.BufferedStream.ReadByte()
   at Npgsql.NpgsqlState.ProcessBackendResponses_Ver_3(NpgsqlConnector
context)
   at Npgsql.NpgsqlState.ProcessBackendResponses(NpgsqlConnector context)
   at Npgsql.NpgsqlReadyState.Query(NpgsqlConnector context,
NpgsqlCommand comm
nd)
   at Npgsql.NpgsqlConnector.Query(NpgsqlCommand queryCommand)
   at Npgsql.NpgsqlCommand.ExecuteCommand()
   at Npgsql.NpgsqlCommand.ExecuteScalar()
   at c.Main(String[] args)



Checking mono source, it seems that it ends calling
System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32
size SocketFlags socketFlags) too from NetworkStream.Read().

Socket.Receive ends up calling Receive_nochecks which seems is not
realizing that the connection is broken and returns ok which makes
Receive returns ok without throwing any SocketException.

Can you confirm that?

The closest bug I could find about that is this:
http://bugzilla.ximian.com/show_bug.cgi?id=63233

But it talks about async calls which isn't my case.

If you can confirm that, I can fill a bug report.

Thanks in advance.


- --
Regards,

Francisco Figueiredo Jr.
http://fxjr.blogspot.com
Npgsql Lead Developer
http://pgfoundry.org/projects/npgsql
Mono Project Contributor
http://www.go-mono.com
MonoBrasil Project Founder Member
http://monobrasil.softwarelivre.org


- --
 - Would you tell me, please, which way I ought to go from here?
 - That depends a good deal on where you want to get to.
 		-- Lewis Carroll "Alice's Adventures in Wonderland"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.4 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQEVAwUBRP2FbP7iFmsNzeXfAQJGkQgAn/oknk5yYc1Wu8ES/SUo3bq5OTGKoliY
m61V6NzCDxylVPiXcPUaFjfjisXMQuwr3KgCs5IigLAyyff/odOLbuTcQk0y6SqE
xmMv85yPpW//ZEuAoLzVzg5cxyhGWSBCtdbVWGZKFcDbm5eTixHvIVO+x0KGx34c
8BniK6RNq0wnQTk9k2ytlvopfegmeDBVsnsbJa9dbD/hdwMbi1kCYcxQbWSZgHHv
313PanjLx26Pui1OY/DqjHT1hGvLt3wVbfdLvkb4usEa+JwEm+kU0JAE3jWU0QDF
L5ECTwFWabZ0G3mtqd6gz3YQPENjSKaOsOfEpybFDtpjvWbrn1PEVA==
=G7K0
-----END PGP SIGNATURE-----

		
_______________________________________________________ 
O Yahoo! está de cara nova. Venha conferir! 
http://br.yahoo.com


More information about the Mono-list mailing list