[Mono-bugs] [Bug 38186][Wis] New - Problem using Receive method of a Socket

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Mon, 17 Feb 2003 06:47:02 -0500 (EST)


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 carlosga@telefonica.net.

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

--- shadow/38186	Mon Feb 17 06:47:02 2003
+++ shadow/38186.tmp.6615	Mon Feb 17 06:47:02 2003
@@ -0,0 +1,86 @@
+Bug#: 38186
+Product: Mono/Class Libraries
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: System
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: carlosga@telefonica.net               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Problem using Receive method of a Socket
+
+Hello:
+
+
+I'm having problems using the Receive method of a Socket, i get an
+exception when i exec it ( it doesn't block until Receive returns before
+raise the exception )
+
+Unhandled Exception: System.ArgumentOutOfRangeException: Argument is out of
+range
+Parameter name: offset exceeds the size of bufferin <0x00088> 00
+System.Net.Sockets.Socket:Receive
+(byte[],int,int,System.Net.Sockets.SocketFlags)
+in <0x00108> 00 SocketTest.Test:Main (string[])
+
+
+
+Here is the test case, it works as expected in MS .Net but not in mono:
+
+
+using System;
+
+using System.Net;
+
+using System.Net.Sockets;
+
+
+
+
+
+namespace SocketTest
+
+{
+
+	public class Test
+
+	{
+
+		public static void Main(string[] args)
+
+		{
+			IPAddress	hostadd = Dns.Resolve("messenger.hotmail.com").AddressList[0];
+
+			IPEndPoint	remoteEP = new IPEndPoint(hostadd, 1863);
+
+
+			Socket socket = new Socket(AddressFamily.InterNetwork,
+				SocketType.Stream,
+				ProtocolType.Tcp);
+
+			socket.Connect(remoteEP);
+
+			byte[]	buffer = new byte[socket.Available];
+			// This have to block until Receive returns - but it gives an exception
+using mono.
+			int readed = socket.Receive(buffer, 0, socket.Available, SocketFlags.None);
+			
+			Console.WriteLine("Socket cerrado");
+
+			socket.Shutdown(SocketShutdown.Both);		
+			socket.Close();
+
+			Console.ReadLine();
+
+		}
+
+	}
+
+}