internal void Discover(NetPeer peer) { string content = "M-SEARCH * HTTP/1.1\r\n" + "HOST: 239.255.255.250:1900\r\n" + "ST:upnp:rootdevice\r\n" + "MAN:\"ssdp:discover\"\r\n" + "MX:3\r\n\r\n"; m_discoveryResponseDeadline = NetTime.Now + 6.0; // arbitrarily chosen number, router gets 6 seconds to respond m_status = UPnPStatus.Discovering; byte[] raw = System.Text.Encoding.UTF8.GetBytes(content); m_peer.LogDebug("Attempting UPnP discovery"); peer.Socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true); if (peer.Configuration.BroadcastAddress.Equals(IPAddress.Broadcast)) { foreach (IPAddress address in NetUtility.GetBroadcastAddresses()) { peer.RawSend(raw, 0, raw.Length, new NetEndPoint(address, 1900)); } } else { peer.RawSend(raw, 0, raw.Length, new NetEndPoint(peer.Configuration.BroadcastAddress, 1900)); } peer.Socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, false); }
internal void Discover(NetPeer peer) { string str = "M-SEARCH * HTTP/1.1\r\n" + "HOST: 239.255.255.250:1900\r\n" + "ST:upnp:rootdevice\r\n" + "MAN:\"ssdp:discover\"\r\n" + "MX:3\r\n\r\n"; byte[] arr = System.Text.Encoding.UTF8.GetBytes(str); peer.Socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true); peer.RawSend(arr, 0, arr.Length, new IPEndPoint(IPAddress.Broadcast, 1900)); peer.Socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, false); }
internal void Discover(NetPeer peer) { string str = "M-SEARCH * HTTP/1.1\r\n" + "HOST: 239.255.255.250:1900\r\n" + "ST:upnp:rootdevice\r\n" + "MAN:\"ssdp:discover\"\r\n" + "MX:3\r\n\r\n"; byte[] arr = System.Text.Encoding.UTF8.GetBytes(str); peer.Socket.Broadcast = true; peer.RawSend(arr, 0, arr.Length, new IPEndPoint(IPAddress.Broadcast, 1900)); peer.Socket.Broadcast = false; // allow some extra time for router to respond // System.Threading.Thread.Sleep(50); }
internal void Discover(NetPeer peer) { string str = "M-SEARCH * HTTP/1.1\r\n" + "HOST: 239.255.255.250:1900\r\n" + "ST:upnp:rootdevice\r\n" + "MAN:\"ssdp:discover\"\r\n" + "MX:3\r\n\r\n"; m_discoveryResponseDeadline = NetTime.Now + 6.0; // arbitrarily chosen number, router gets 6 seconds to respond m_status = UPnPStatus.Discovering; byte[] arr = System.Text.Encoding.UTF8.GetBytes(str); m_peer.LogDebug("Attempting UPnP discovery"); peer.Socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true); peer.RawSend(arr, 0, arr.Length, new NetEndPoint(NetUtility.GetBroadcastAddress(), 1900)); peer.Socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, false); }