public KnxIpTunneling(IPEndPoint sendEndPoint, bool sendBroadcast = false) { Port = GetFreePort(); _sendEndPoint = sendEndPoint; IPAddress ip = null; try { using (Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, 0)) { socket.Connect("8.8.8.8", 65530); IPEndPoint endPoint = socket.LocalEndPoint as IPEndPoint; ip = endPoint.Address; } } catch { } if (ip == null) { throw new Exception("Lokale Ip konnte nicht gefunden werden"); } _receiveEndPoint = new IPEndPoint(ip, Port); _receiveParserDispatcher = new ReceiverParserDispatcher(); _sendMessages = new BlockingCollection <object>(); Init(sendBroadcast); }
public KnxIpTunneling(IPEndPoint sendEndPoint, bool sendBroadcast = false) { Port = GetFreePort(); _sendEndPoint = sendEndPoint; IPAddress ip = GetIpAddress(sendEndPoint.Address.ToString()); if (ip == null) { throw new Exception("Lokale Ip konnte nicht gefunden werden"); } _receiveEndPoint = new IPEndPoint(ip, Port); _receiveParserDispatcher = new ReceiverParserDispatcher(); _sendMessages = new BlockingCollection <object>(); Init(sendBroadcast); }