?

Log in

No account? Create an account
more testing needed - brad's life — LiveJournal [entries|archive|friends|userinfo]
Brad Fitzpatrick

[ website | bradfitz.com ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

more testing needed [Dec. 26th, 2003|06:30 pm]
Brad Fitzpatrick
Sorry, still haven't setup vmware. Can somebody on Windows run this and tell me the results?

http://www.bradfitz.com/share/mono/AsyncErrorDemo2.exe

Source is here, if you're paranoid about running unknown binaries. You can compile it with:

c:\> csc AsyncErrorDemo2.cs

(Assuming you have the .NET SDK installed....)
LinkReply

Comments:
[User Picture]From: teferi
2003-12-26 06:43 pm (UTC)
demo start
demo middle (before EndSend)
exception: System.Net.Sockets.SocketException: An unexpected network error occurred
at System.Net.Sockets.Socket.EndSend(IAsyncResult asyncResult)
at Danga.syncErrorDemo2.Main()
demo end

as before, WinXP Pro, latest .NET framework, compiled with VS.NET
(Reply) (Thread)
[User Picture]From: brad
2003-12-26 06:45 pm (UTC)
That 1.0 or 1.1 .NET?

I get something totally different on my girlfriend's not-latest Windows XP machine. (which I just discovered was at my house)
(Reply) (Parent) (Thread)
[User Picture]From: taral
2003-12-26 07:08 pm (UTC)
Maybe it's because he compiled with VS.NET instead of mono?
(Reply) (Parent) (Thread)
[User Picture]From: brad
2003-12-26 07:12 pm (UTC)
Good point.

I thought all the relevant code was in the mscorlib.dll, so the exe made by mono vs. VS.NET shouldn't matter, but it may.

I'll check this out on the girlfriend's laptop while I still have it.
(Reply) (Parent) (Thread)
[User Picture]From: dakus
2003-12-26 06:44 pm (UTC)
Unhandled Exception: System.Net.Sockets.SocketException: Unknown error (0x2749)at System.Net.Sockets.Socket.BeginSend(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, AsyncCallback callback, Object state)at Danga.AsyncErrorDemo2.Main()

can run it on other machines if that'll help...
(Reply) (Thread)
[User Picture]From: brad
2003-12-26 06:47 pm (UTC)
That just base XP?
(Reply) (Parent) (Thread)
[User Picture]From: dakus
2003-12-26 06:53 pm (UTC)
same error on XP-pro, and a 98se machine...

and I looked they both have .NET 1.1 on them

there's a 2000 and 2003 machine I can flip on right next to me...
(Reply) (Parent) (Thread)
[User Picture]From: dakus
2003-12-26 06:56 pm (UTC)
ok, it's not the same...here's the XP

Unhandled Exception: System.Net.Sockets.SocketException: A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied
at System.Net.Sockets.Socket.BeginSend(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, AsyncCallback callback, Object state)
at Danga.AsyncErrorDemo2.Main()
(Reply) (Parent) (Thread)
[User Picture]From: funjon
2003-12-26 06:45 pm (UTC)
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\> asyncerrordemo2
demo start

Unhandled Exception: System.Net.Sockets.SocketException: A request to send or re
ceive data was disallowed because the socket is not connected and (when sending
on a datagram socket using a sendto call) no address was supplied
at System.Net.Sockets.Socket.BeginSend(Byte[] buffer, Int32 offset, Int32 siz
e, SocketFlags socketFlags, AsyncCallback callback, Object state)
at Danga.AsyncErrorDemo2.Main()
(Reply) (Thread)
[User Picture]From: brad
2003-12-26 06:46 pm (UTC)
That's what I get on my girlfriend's XP machine too. But I was expecting to get what teferi posted above.
(Reply) (Parent) (Thread)
[User Picture]From: taral
2003-12-26 07:11 pm (UTC)
Dude:
the socket is not connected
And indeed, you never did connect it...
(Reply) (Thread)
[User Picture]From: brad
2003-12-26 07:14 pm (UTC)
That's the point.

I'm testing Microsoft .NET's error handling vs. Mono's.

I should be able to catch the exception around Socket.EndSend.

With Mono, I can't.... it happens in its own thread and there's nothing I can do.

See my previous post for my idea on fixing Mono.
(Reply) (Parent) (Thread)
[User Picture]From: taral
2003-12-26 07:17 pm (UTC)
Uh, no, you need to put an exception handler on the BeginSend, since only asynchronous errors will be thrown in the EndSend. In this case, the Microsoft .NET library detects the error synchronously and throws the exception in BeginSend.
(Reply) (Parent) (Thread)
[User Picture]From: brad
2003-12-26 07:30 pm (UTC)
Well, that's another difference that needs to be taken care of then.

But see the original (longer) test case for the real issue:

http://www.bradfitz.com/share/mono/AsyncErrorDemo.cs

There I have a connected socket where the remote side then goes away, so the sender throws a "SocketException: remote side has gone away!" (or something) and I can't catch it in mono in either BeginWrite or EndWrite (which just call Socket.BeginSend/EndSend).

My goal is for all the error handling to be the same, so thanks for pointing out the not-connected issue. I'm downloading the .NET SDK now for Windows, and I'll work on making a bunch of little test cases.
(Reply) (Parent) (Thread)
[User Picture]From: taral
2003-12-26 07:48 pm (UTC)
Hmm. Well, first mistake I see in that is that you're not waiting for the sender to die, the exit will kill the async thread before the close is noticed in some cases. Perhaps try a sleep after the join?
(Reply) (Parent) (Thread)
[User Picture]From: mart
2003-12-27 03:56 am (UTC)

I disassembled the code generated by both Mono's and Microsoft's C# compiler, and then diffed them. Aside from a few operational differences (MS uses a helper function to act on your array literal, for example) the only real difference I can see is that Microsoft's code leaves the exception handler with leave.s while mono generates leave… I don't know IL enough to know what difference that makes, if any! ;)

(Reply) (Thread)