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

Function FindConnection

engine/dlib/src/dlib/connection_pool.cpp:191–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189 }
190
191 static bool FindConnection(HPool pool, dmhash_t id, dmSocket::Address address, uint16_t port, bool ssl, HConnection* connection)
192 {
193 uint32_t n = pool->m_Connections.Size();
194 for (uint32_t i = 0; i < n; ++i) {
195 Connection* c = &pool->m_Connections[i];
196 if (c->m_State == STATE_CONNECTED && c->m_ID == id) {
197 // We have to return a socket with the correct address family
198 bool ipv4_match = address.m_family == dmSocket::DOMAIN_IPV4 && dmSocket::IsSocketIPv4(c->m_Socket);
199 bool ipv6_match = address.m_family == dmSocket::DOMAIN_IPV6 && dmSocket::IsSocketIPv6(c->m_Socket);
200 if (ipv4_match || ipv6_match)
201 {
202 c->m_State = STATE_INUSE;
203 c->m_ReuseCount++;
204 *connection = MakeHandle(pool, i, c);
205 return true;
206 }
207 }
208 }
209
210 return false;
211 }
212
213 static void DoClose(HPool pool, Connection* c)
214 {

Callers 1

DoDialFunction · 0.85

Calls 4

IsSocketIPv4Function · 0.70
IsSocketIPv6Function · 0.70
MakeHandleFunction · 0.70
SizeMethod · 0.45

Tested by

no test coverage detected