You've already forked linux-packaging-mono
Imported Upstream version 4.3.2.467
Former-commit-id: 9c2cb47f45fa221e661ab616387c9cda183f283d
This commit is contained in:
@@ -1 +1 @@
|
||||
f8c2f4cb750d69cbda8d81e1312338786dae656f
|
||||
2f85b7b795ef33f0b58ccc3b51269444520bdab9
|
@@ -13,6 +13,8 @@ using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using NUnit.Framework;
|
||||
|
||||
using MonoTests.Helpers;
|
||||
|
||||
namespace MonoTests.System.Net.Sockets
|
||||
{
|
||||
/// <summary>
|
||||
@@ -76,9 +78,7 @@ namespace MonoTests.System.Net.Sockets
|
||||
public void CloseTest ()
|
||||
{
|
||||
IPEndPoint localEP = new IPEndPoint (IPAddress.Loopback, 8765);
|
||||
using (SocketResponder sr = new SocketResponder (localEP, new SocketRequestHandler (CloseRequestHandler))) {
|
||||
sr.Start ();
|
||||
|
||||
using (SocketResponder sr = new SocketResponder (localEP, s => CloseRequestHandler (s))) {
|
||||
TcpClient tcpClient = new TcpClient (IPAddress.Loopback.ToString (), 8765);
|
||||
NetworkStream ns = tcpClient.GetStream ();
|
||||
Assert.IsNotNull (ns, "#A1");
|
||||
@@ -103,9 +103,7 @@ namespace MonoTests.System.Net.Sockets
|
||||
*/
|
||||
}
|
||||
|
||||
using (SocketResponder sr = new SocketResponder (localEP, new SocketRequestHandler (CloseRequestHandler))) {
|
||||
sr.Start ();
|
||||
|
||||
using (SocketResponder sr = new SocketResponder (localEP, s => CloseRequestHandler (s))) {
|
||||
TcpClient tcpClient = new TcpClient (IPAddress.Loopback.ToString (), 8765);
|
||||
Assert.AreEqual (0, tcpClient.Available, "#B1");
|
||||
Assert.IsTrue (tcpClient.Connected, "#B2");
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user