Imported Upstream version 4.3.2.467

Former-commit-id: 9c2cb47f45fa221e661ab616387c9cda183f283d
This commit is contained in:
Xamarin Public Jenkins
2016-02-22 11:00:01 -05:00
parent f302175246
commit f3e3aab35a
4097 changed files with 122406 additions and 82300 deletions

View File

@ -9,6 +9,7 @@ using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Threading.Tasks;
using NUnit.Framework;
@ -830,31 +831,37 @@ namespace MonoTests.System.Net.Sockets {
{
UdpClient client = null;
var rnd = new Random ();
for (int i = 0; i < 5; i++) {
for (int i = 0, max = 5; i < max; i++) {
int port = rnd.Next (1025, 65534);
try {
client = new UdpClient (port);
break;
} catch (Exception) {
if (i == 5)
if (i == max - 1)
throw;
}
}
new Thread(delegate() {
Thread.Sleep(2000);
client.Close();
}).Start();
ManualResetEvent ready = new ManualResetEvent (false);
bool got_exc = false;
IPEndPoint ep = new IPEndPoint (IPAddress.Any, 0);
try {
client.Receive(ref ep);
} catch (SocketException) {
got_exc = true;
} finally {
client.Close ();
}
Task receive_task = Task.Factory.StartNew (() => {
IPEndPoint ep = new IPEndPoint (IPAddress.Any, 0);
try {
ready.Set ();
client.Receive(ref ep);
} catch (SocketException) {
got_exc = true;
} finally {
client.Close ();
}
});
ready.WaitOne (2000);
Thread.Sleep (20);
client.Close();
Assert.IsTrue (receive_task.Wait (1000));
Assert.IsTrue (got_exc);
}