Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. public static string GetIPs(string args)
  2. {
  3. string[] combinedString;
  4. List<string> IPAdressenLijst = new List<string>();
  5. IPAddress[] ips = Dns.GetHostAddresses(Dns.GetHostName());
  6.  
  7. foreach (IPAddress ip in ips)
  8. {
  9. if (ip.AddressFamily == AddressFamily.InterNetwork)
  10. {
  11. if (args == "program")
  12. {
  13. IPAdressenLijst.Add("http://" + ip + ":1337/");
  14. combinedString = IPAdressenLijst.ToArray();
  15. }
  16. else if (args == "webserver")
  17. {
  18. IPAdressenLijst.Add("http://" + ip + ":1337/start/");
  19. IPAdressenLijst.Add("http://" + ip + ":1337/stop/");
  20. combinedString = IPAdressenLijst.ToArray();
  21. }
  22. }
  23. }
  24. return combinedString[0];
  25. }
  26.  
  27. static void Main(string[] args)
  28. {
  29. Console.WriteLine(DateTime.Now + " Press any key to exit.");
  30. //WebServer ws = new WebServer(SendResponse, "http://192.168.0.107:1337/", "http://localhost:1337/");
  31. WebServer ws = new WebServer(SendResponse, IPs.GetIPs("program"));
  32. ws.Run();
  33. Console.ReadKey();
  34. ws.Stop();
  35. }
  36.  
  37. public class WebServer
  38. {
  39. //static string[] uris =
  40. //{
  41. // "http://192.168.0.107:1337/start/",
  42. // "http://192.168.0.107:1337/stop/"
  43. //};
  44. static string[] uris =
  45. {
  46. IPs.GetIPs("webserver")
  47. };
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement