[Mono-bugs] [Bug 60811][Cri] New - Asynchronous Socket Callbacks dont work.

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sun, 27 Jun 2004 20:45:05 -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 draek@shaw.ca.

http://bugzilla.ximian.com/show_bug.cgi?id=60811

--- shadow/60811	2004-06-27 20:45:05.000000000 -0400
+++ shadow/60811.tmp.5414	2004-06-27 20:45:05.000000000 -0400
@@ -0,0 +1,146 @@
+Bug#: 60811
+Product: Mono: Class Libraries
+Version: unspecified
+OS: 
+OS Details: Fedora Core 2
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Critical
+Component: System
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: draek@shaw.ca               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Asynchronous Socket Callbacks dont work.
+
+Description of Problem:
+
+Since upgrading to RC1 of Mono, I am no longer receiving Asynchronous
+callbacks from Socket objects. Either the sockets are no longer connecting
+to where they should, or the callbacks arent being called.
+
+Unfortunately I'm still new to the system, and I used a new GTK# example to
+show you what happens, this is my window class, you just need to create it
+in a new application main class to run it. the constructor will create the
+socket.
+
+Code Example that reproduces the problem:
+
+using System;
+using System.Net;
+using System.Net.Sockets;
+using Gtk;
+
+public class MyWindow : Window {
+	private AsyncCallback m_pCallbackConnectMethod;
+	private AsyncCallback pCallbackConnectMethod { get { return
+m_pCallbackConnectMethod; } set { m_pCallbackConnectMethod = value; } }
+	
+	private System.Net.Sockets.Socket m_objClientSocket;
+
+	public System.Net.Sockets.Socket objClientSocket { get { return
+m_objClientSocket; } set { m_objClientSocket = value; } }
+	
+	private IPEndPoint m_objEndPoint;
+	public IPEndPoint objEndPoint { get { return m_objEndPoint; } set {
+m_objEndPoint = value; } }
+	
+	public MyWindow () : base ("MyWindow")
+	{
+		this.pCallbackConnectMethod = new AsyncCallback(ConnectComplete);
+		this.SetDefaultSize (400, 300);
+		this.DeleteEvent += new DeleteEventHandler (OnMyWindowDelete);
+		this.ShowAll ();
+		this.Connect();
+	}
+	
+	public void Connect() {	
+		Console.WriteLine("Connecting to MSN service...");
+		
+
+		if(this.objClientSocket == null) {
+			// Create the socket object.
+			this.objClientSocket = new
+System.Net.Sockets.Socket(AddressFamily.InterNetwork, SocketType.Stream,
+ProtocolType.Tcp);
+		
+			// Set some socket options.
+		
+this.objClientSocket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Socket,
+System.Net.Sockets.SocketOptionName.ReceiveBuffer, 1048576);
+
+		
+this.objClientSocket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Socket,
+System.Net.Sockets.SocketOptionName.SendBuffer, 1048576);
+
+		
+this.objClientSocket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Tcp,
+   System.Net.Sockets.SocketOptionName.NoDelay, 1);
+			
+			this.objEndPoint = new
+IPEndPoint(Dns.Resolve("messenger.hotmail.com").AddressList[0], 1863);
+		}
+		try {
+			this.objClientSocket.Blocking = false;
+
+			// Attempt to establish a connection
+			Console.WriteLine("Connect> Host:
+"+this.objEndPoint.Address.ToString()+", Port:
+"+this.objEndPoint.Port.ToString()+".");
+			this.objClientSocket.BeginConnect(this.objEndPoint, new
+AsyncCallback(ConnectComplete), this.objClientSocket);
+
+		} catch (System.Net.Sockets.SocketException e) {
+			Console.WriteLine("!Socket Exception!: "+e.Message);
+
+		} catch (System.Exception e) {
+			Console.WriteLine("!Exception!: "+e.Message);
+		}
+
+	}
+	
+	private void ConnectComplete(IAsyncResult ar) {
+		System.Net.Sockets.Socket objSocket =
+(System.Net.Sockets.Socket)ar.AsyncState;
+		
+	 	try {
+	 		objSocket.EndConnect(ar);
+			if(objSocket.Connected == false) {
+       			Console.WriteLine( "Connect> Connection Failed! Host:
+"+objSocket.RemoteEndPoint.ToString());
+       			return;
+     			} else Console.WriteLine("Connect> Connection Successfull!");
+	 	} catch(SocketException e) {
+	 		return;
+	 	}		
+	}
+	
+	void OnMyWindowDelete (object o, DeleteEventArgs args)
+	{
+		Application.Quit ();
+	}
+}
+
+Actual Results:
+Opens up the socket, and goes into the program loop. The callback never
+comes back (however we both know the MSN server is there and listening,
+since my MSN account can be logged in easily.
+
+This exact concept worked in Beta3.
+
+Expected Results:
+Socket connection to be made, and a callback to be called. Either
+connection, disconnection, error, etc (no errors or timeouts occur).
+
+How often does this happen? 
+
+Everytime.
+
+Additional Information:
+
+We have a GNOME MSN client we are building, and it used to work in Beta 3
+(we are just in the process of going backwards to beta 3) and stopped
+working in RC1.