Skip to content

Commit

Permalink
Display possible UDPWii server addresses on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
EZForever committed Jun 30, 2021
1 parent b502f0e commit 9bf8e9c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions UDPWiiHook/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.Net;
using System.Linq;
using System.Net.Sockets;

namespace UDPWiiHook
Expand All @@ -21,10 +23,19 @@ public static void Main(string[] args)
new UDPWii.Server(id, 2, 4436),
new UDPWii.Server(id, 3, 4437)
};

Console.WriteLine("[Program] Possible UDPWii.Server addresses:");
Dns.GetHostEntry(Dns.GetHostName()).AddressList
.Where(x => x.AddressFamily == AddressFamily.InterNetwork)
.Select(x => x.ToString())
.Where(x => !x.StartsWith("169.254."))
.ToList()
.ForEach(x => Console.WriteLine("\t" + x));
}
catch(SocketException)
catch(SocketException e)
{
Console.Error.WriteLine("[Program] SocketException (running multiple instances?)");
Console.Error.WriteLine("[Program] SocketException (running multiple instances?):");
Console.Error.WriteLine("\t" + e.Message);
return;
}

Expand Down

0 comments on commit 9bf8e9c

Please sign in to comment.