MCPcopy Create free account
hub / github.com/defold/defold / HandleBrowserResponses

Function HandleBrowserResponses

engine/dlib/src/dlib/mdns.cpp:2092–2173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2090 }
2091
2092 static void HandleBrowserResponses(Browser* browser)
2093 {
2094 bool incoming_data = false;
2095 do
2096 {
2097 incoming_data = false;
2098 dmSocket::Selector selector;
2099 dmSocket::SelectorZero(&selector);
2100 dmSocket::SelectorSet(&selector, dmSocket::SELECTOR_KIND_READ, browser->m_Socket);
2101
2102 if (dmSocket::Select(&selector, 0) != dmSocket::RESULT_OK)
2103 return;
2104
2105 if (!dmSocket::SelectorIsSet(&selector, dmSocket::SELECTOR_KIND_READ, browser->m_Socket))
2106 return;
2107
2108 dmSocket::Address from_address;
2109 uint16_t from_port = 0;
2110 int received = 0;
2111 dmSocket::Result sr = dmSocket::ReceiveFrom(browser->m_Socket, browser->m_Buffer, sizeof(browser->m_Buffer), &received, &from_address, &from_port);
2112 if (sr != dmSocket::RESULT_OK || received <= 0)
2113 return;
2114
2115 incoming_data = true;
2116
2117 (void) from_address;
2118 (void) from_port;
2119
2120 uint32_t size = (uint32_t) received;
2121 if (size < 12)
2122 continue;
2123
2124 uint32_t offset = 0;
2125 uint16_t id = 0;
2126 uint16_t flags = 0;
2127 uint16_t qdcount = 0;
2128 uint16_t ancount = 0;
2129 uint16_t nscount = 0;
2130 uint16_t arcount = 0;
2131
2132 if (!ReadU16(browser->m_Buffer, size, &offset, &id)
2133 || !ReadU16(browser->m_Buffer, size, &offset, &flags)
2134 || !ReadU16(browser->m_Buffer, size, &offset, &qdcount)
2135 || !ReadU16(browser->m_Buffer, size, &offset, &ancount)
2136 || !ReadU16(browser->m_Buffer, size, &offset, &nscount)
2137 || !ReadU16(browser->m_Buffer, size, &offset, &arcount))
2138 {
2139 continue;
2140 }
2141
2142 (void) id;
2143
2144 if ((flags & 0x8000) == 0)
2145 continue;
2146
2147 // Skip query sections.
2148 for (uint16_t i = 0; i < qdcount; ++i)
2149 {

Callers 1

UpdateBrowserFunction · 0.85

Calls 8

SelectorZeroFunction · 0.85
SelectorSetFunction · 0.85
SelectorIsSetFunction · 0.85
HandleBrowserRecordFunction · 0.85
SelectFunction · 0.70
ReceiveFromFunction · 0.70
ReadU16Function · 0.70
ReadNameFunction · 0.70

Tested by

no test coverage detected