static string NetSetup() { receiver = new UdpClient(local); sender = new UdpClient(local_); ss = new UdpState(); ss.e = local; ss.u = sender; rs = new UdpState(); rs.e = local; rs.u = receiver; Console.WriteLine("Network for web started"); try { receiver.BeginReceive(new AsyncCallback(OnReceive), rs); } catch (SocketException e) { Console.WriteLine(e.Message); } IPHostEntry host; string localIP = "?"; host = Dns.GetHostEntry(Dns.GetHostName()); foreach (IPAddress ip in host.AddressList) { if (ip.AddressFamily == AddressFamily.InterNetwork) { localIP = ip.ToString(); } } return(localIP); }
static string NetSetup() { receiver = new UdpClient(local); sender = new UdpClient(local_); ss = new UdpState(); ss.e = local; ss.u = sender; rs = new UdpState(); rs.e = local; rs.u = receiver; Console.WriteLine("Network for web started"); try { receiver.BeginReceive(new AsyncCallback(OnReceive), rs); } catch (SocketException e) { Console.WriteLine(e.Message); } IPHostEntry host; string localIP = "?"; host = Dns.GetHostEntry(Dns.GetHostName()); foreach (IPAddress ip in host.AddressList) { if (ip.AddressFamily == AddressFamily.InterNetwork) { localIP = ip.ToString(); } } return localIP; }