diff options
Diffstat (limited to 'mcs/class/System/Test/System.Net.Sockets')
-rwxr-xr-x[-rw-r--r--] | mcs/class/System/Test/System.Net.Sockets/SocketTest.cs | 48 | ||||
-rw-r--r-- | mcs/class/System/Test/System.Net.Sockets/UdpClientTest.cs | 23 |
2 files changed, 62 insertions, 9 deletions
diff --git a/mcs/class/System/Test/System.Net.Sockets/SocketTest.cs b/mcs/class/System/Test/System.Net.Sockets/SocketTest.cs index 6f0e4cf3ee..4bd26f9fae 100644..100755 --- a/mcs/class/System/Test/System.Net.Sockets/SocketTest.cs +++ b/mcs/class/System/Test/System.Net.Sockets/SocketTest.cs @@ -4144,6 +4144,54 @@ namespace MonoTests.System.Net.Sockets } [Test] + public void SetSocketOption_MulticastInterfaceIndex_Any () + { + IPAddress ip = IPAddress.Parse ("239.255.255.250"); + int index = 0; + using (Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)) + { + s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastInterface, IPAddress.HostToNetworkOrder(index)); + s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(ip, index)); + } + } + + [Test] + public void SetSocketOption_MulticastInterfaceIndex_Loopback () + { + IPAddress ip = IPAddress.Parse ("239.255.255.250"); + int index = 1; + using (Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)) + { + s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastInterface, IPAddress.HostToNetworkOrder(index)); + s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(ip, index)); + } + } + + [Test] + public void SetSocketOption_MulticastInterfaceIndex_Invalid () + { + IPAddress ip = IPAddress.Parse ("239.255.255.250"); + int index = 31415; + using (Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)) + { + try + { + s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastInterface, IPAddress.HostToNetworkOrder(index)); + Assert.Fail ("#1"); + } + catch + {} + try + { + s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(ip, index)); + Assert.Fail ("#2"); + } + catch + {} + } + } + + [Test] public void Shutdown_NoConnect () { Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); diff --git a/mcs/class/System/Test/System.Net.Sockets/UdpClientTest.cs b/mcs/class/System/Test/System.Net.Sockets/UdpClientTest.cs index 6fa403c607..710b4982c1 100644 --- a/mcs/class/System/Test/System.Net.Sockets/UdpClientTest.cs +++ b/mcs/class/System/Test/System.Net.Sockets/UdpClientTest.cs @@ -1051,16 +1051,21 @@ namespace MonoTests.System.Net.Sockets { [Test] public void Available () { - UdpClient client = new UdpClient (1238); - IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 1238); - byte[] bytes = new byte[] {10, 11, 12, 13}; - - client.Send (bytes, bytes.Length, ep); - int avail = client.Available; - - Assert.AreEqual (bytes.Length, avail, "Available #1"); + using (UdpClient client = new UdpClient (1238)) { + IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 1238); + byte[] bytes = new byte[] {10, 11, 12, 13}; + + int res = client.Send (bytes, bytes.Length, ep); + Assert.AreEqual (bytes.Length, res, "Send"); + + // that might happen too quickly, data sent and not yet received/available + Thread.Sleep (100); + int avail = client.Available; + + Assert.AreEqual (bytes.Length, avail, "Available #1"); - client.Close (); + client.Close (); + } } [Test] |