[Mono-bugs] [Bug 45875][Cri] New - Async Sockets Operations fail
bugzilla-daemon@rocky.ximian.com
bugzilla-daemon@rocky.ximian.com
Sun, 6 Jul 2003 07:35:29 -0400 (EDT)
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by giuseppe.greco@agamura.com.
http://bugzilla.ximian.com/show_bug.cgi?id=45875
--- shadow/45875 Sun Jul 6 07:35:29 2003
+++ shadow/45875.tmp.10422 Sun Jul 6 07:35:29 2003
@@ -0,0 +1,116 @@
+Bug#: 45875
+Product: Mono/Class Libraries
+Version: unspecified
+OS: Red Hat 9.0
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Critical
+Component: System
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: giuseppe.greco@agamura.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Summary: Async Sockets Operations fail
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+
+Description of Problem:
+Async sockets operations do not work (see the small program
+here below).
+
+
+Steps to reproduce the problem:
+
+1. Write a small application like this:
+
+using System;
+using System.Net;
+using System.Net.Sockets;
+using System.Threading;
+
+
+public class MySender
+{
+ private static bool sent = false;
+
+
+ public static void Main()
+ {
+ byte[] data = new byte[10];
+ for (int i = 0; i < 10; i++) {
+ data[i] = (byte) i;
+ }
+
+
+ EndPoint endPoint=
+ (EndPoint) new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9000);
+
+
+ Socket socket = new Socket(
+ AddressFamily.InterNetwork,
+ SocketType.Dgram,
+ ProtocolType.Udp);
+
+
+ socket.BeginSendTo(
+ data,
+ 0,
+ data.Length,
+ SocketFlags.None,
+ endPoint,
+ new AsyncCallback(new MySender().AsyncSend),
+ socket);
+
+
+ while (!sent) {
+ Thread.Sleep(10);
+ }
+ }
+
+
+ void AsyncSend(IAsyncResult ar)
+ {
+ Socket socket = (Socket) ar;
+ socket.EndSendTo(ar);
+ sent = true;
+ }
+}
+
+
+2. Compile it:
+ mcs -t:exe -out:test.exe *.cs
+
+
+3. Run it:
+ mono ./test.exe
+
+
+Actual Results:
+The application above crashes and reports the
+following error messages:
+
+Unhandled Exception: System.InvalidCastException:
+Cannot cast from source type t o destination type
+in <0x00027> 00 .MySender:AsyncSend (System.IAsyncResult)
+in <0x0004e> 01 System.MulticastDelegate:invoke_void_IAsyncResult
+(System.IAsync Result)
+in <0x0009c> 00 .Worker:End ()
+in <0x00077> 00 .Worker:SendTo ()
+in <0x00043> 01 System.MulticastDelegate:invoke_void ()
+
+
+Expected Results:
+The application should send the datagram
+without crashing.
+
+
+How often does this happen?
+Always.
+
+
+Additional Information:
+This application works fine with .NET on Windows.