Socket s;
IPEndPoint localEP;
- client = new MyUdpClient ("localhost", IPEndPoint.MinPort);
+ // Bug #5503
+ // UDP port 0 doesn't seem to be valid.
+ client = new MyUdpClient ("127.0.0.1", 53);
s = client.Client;
Assert.IsNotNull (s, "#A:Client");
Assert.AreEqual (AddressFamily.InterNetwork, s.AddressFamily, "#A:Client:AddressFamily");
Assert.AreEqual (IPAddress.Loopback, localEP.Address, "#A:Client:LocalEndPoint/Address");
Assert.AreEqual (AddressFamily.InterNetwork, localEP.AddressFamily, "#A:Client:LocalEndPoint/AddressFamily");
- client = new MyUdpClient ("localhost", IPEndPoint.MaxPort);
+ client = new MyUdpClient ("127.0.0.1", IPEndPoint.MaxPort);
s = client.Client;
Assert.IsNotNull (s, "#B:Client");
Assert.AreEqual (AddressFamily.InterNetwork, s.AddressFamily, "#B:Client:AddressFamily");
[Test]
public void UdpClientBroadcastTest ()
{
- UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234));
+ UdpClient client = new UdpClient ();
byte[] bytes = new byte[] {10, 11, 12, 13};
try {
[Test]
public void CloseInReceive ()
{
- UdpClient client = new UdpClient (50000);
+ UdpClient client = null;
+ var rnd = new Random ();
+ for (int i = 0; i < 5; i++) {
+ int port = rnd.Next (1025, 65534);
+ try {
+ client = new UdpClient (port);
+ break;
+ } catch (Exception ex) {
+ if (i == 5)
+ throw;
+ }
+ }
+
new Thread(delegate() {
Thread.Sleep(2000);
client.Close();