From f75e3a4aac5f605084b2f24fe030d46f15dd7f11 Mon Sep 17 00:00:00 2001 From: Dick Porter Date: Tue, 23 Jan 2007 21:08:28 +0000 Subject: 2007-01-23 Dick Porter * TcpClient.cs: 2.0 profile updates, based on a patch by Sridhar Kulkarni (sridharkulkarni@gmail.com) 2007-01-23 Dick Porter * TcpClientTest.cs: Test 2.0 Connect(IPAddress[], port) overload svn path=/trunk/mcs/; revision=71557 --- mcs/class/System/System.Net.Sockets/ChangeLog | 5 ++ mcs/class/System/System.Net.Sockets/TcpClient.cs | 98 ++++++++++++++++++---- mcs/class/System/Test/System.Net.Sockets/ChangeLog | 4 + .../Test/System.Net.Sockets/TcpClientTest.cs | 50 +++++++++++ 4 files changed, 139 insertions(+), 18 deletions(-) diff --git a/mcs/class/System/System.Net.Sockets/ChangeLog b/mcs/class/System/System.Net.Sockets/ChangeLog index 81f14673137..128f68c15a0 100644 --- a/mcs/class/System/System.Net.Sockets/ChangeLog +++ b/mcs/class/System/System.Net.Sockets/ChangeLog @@ -1,3 +1,8 @@ +2007-01-23 Dick Porter + + * TcpClient.cs: 2.0 profile updates, based on a patch by Sridhar + Kulkarni (sridharkulkarni@gmail.com) + 2007-01-22 Miguel de Icaza * Socket.cs: Move the throw new NotImplementedException () diff --git a/mcs/class/System/System.Net.Sockets/TcpClient.cs b/mcs/class/System/System.Net.Sockets/TcpClient.cs index 78177dc2521..c899c9d9c82 100644 --- a/mcs/class/System/System.Net.Sockets/TcpClient.cs +++ b/mcs/class/System/System.Net.Sockets/TcpClient.cs @@ -3,6 +3,7 @@ // Author: // Phillip Pearson (pp@myelin.co.nz) // Gonzalo Paniagua Javier (gonzalo@novell.com) +// Sridhar Kulkarni (sridharkulkarni@gmail.com) // // Copyright (C) 2001, Phillip Pearson // http://www.myelin.co.nz @@ -126,12 +127,10 @@ namespace System.Net.Sockets public bool ExclusiveAddressUse { get { - return !((bool) client.GetSocketOption (SocketOptionLevel.Socket, - SocketOptionName.ReuseAddress)); + return(client.ExclusiveAddressUse); } set { - client.SetSocketOption (SocketOptionLevel.Socket, - SocketOptionName.ReuseAddress, !value); + client.ExclusiveAddressUse = value; } } #endif @@ -310,38 +309,101 @@ namespace System.Net.Sockets public void Connect (string hostname, int port) { - CheckDisposed (); - IPHostEntry host = Dns.GetHostByName(hostname); - for(int i=0; i + + * TcpClientTest.cs: Test 2.0 Connect(IPAddress[], port) overload + 2007-01-11 Dick Porter * SocketTest.cs: diff --git a/mcs/class/System/Test/System.Net.Sockets/TcpClientTest.cs b/mcs/class/System/Test/System.Net.Sockets/TcpClientTest.cs index 8b6aac55a8e..295804b193c 100644 --- a/mcs/class/System/Test/System.Net.Sockets/TcpClientTest.cs +++ b/mcs/class/System/Test/System.Net.Sockets/TcpClientTest.cs @@ -71,6 +71,56 @@ namespace MonoTests.System.Net.Sockets { lSock.Close(); } + +#if NET_2_0 + [Test] + [ExpectedException (typeof(ArgumentNullException))] + public void ConnectMultiNull () + { + TcpClient client = new TcpClient (); + IPAddress[] ipAddresses = null; + + client.Connect (ipAddresses, 1234); + } + + [Test] + public void ConnectMultiAny () + { + TcpClient client = new TcpClient (); + IPAddress[] ipAddresses = new IPAddress[1]; + + ipAddresses[0] = IPAddress.Any; + + try { + client.Connect (ipAddresses, 1234); + Assert.Fail ("ConnectMultiAny #1"); + } catch (SocketException ex) { + Assertion.AssertEquals ("ConnectMultiAny #2", + 10049, ex.ErrorCode); + } catch { + Assert.Fail ("ConnectMultiAny #3"); + } + } + + [Test] + public void ConnectMultiRefused () + { + TcpClient client = new TcpClient (); + IPAddress[] ipAddresses = new IPAddress[1]; + + ipAddresses[0] = IPAddress.Loopback; + + try { + client.Connect (ipAddresses, 1234); + Assert.Fail ("ConnectMultiRefused #1"); + } catch (SocketException ex) { + Assertion.AssertEquals ("ConnectMultiRefused #2", 10061, ex.ErrorCode); + } catch { + Assert.Fail ("ConnectMultiRefused #3"); + } + } + +#endif } -- cgit v1.2.3