MCPcopy Create free account
hub / github.com/MergHQ/CRYENGINE / GetBindAddress

Method GetBindAddress

Code/CryEngine/CryNetwork/Http/SimpleHttpServer.cpp:321–355  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

319#endif
320
321void CSimpleHttpServerInternal::GetBindAddress(TNetAddress& addr, uint16 port) const
322{
323 addr = TNetAddress(SIPv4Addr(0, port));
324#if CRY_PLATFORM_WINDOWS // On windows we should check the sv_bind variable and attempt to play nice and bind to the address requested
325 TNetAddressVec addrs;
326 char address[SHTTP_MAX_ADDRESS_SIZE];
327 CNetAddressResolver resolver;
328
329 cry_sprintf(address, "0.0.0.0:%d", port);
330
331 ICVar* pCVar = gEnv->pConsole->GetCVar("sv_bind");
332 if (pCVar && pCVar->GetString())
333 {
334 if (strlen(pCVar->GetString()) <= SHTTP_MAX_IP_EXPECTED)
335 {
336 cry_sprintf(address, "%s:%d", pCVar->GetString(), port);
337 }
338 else
339 {
340 NetLog("Address to bind '%s' does not appear to be an IP address", pCVar->GetString());
341 }
342 }
343
344 CNameRequestPtr pReq = resolver.RequestNameLookup(address);
345 pReq->Wait();
346 if (pReq->GetResult(addrs) != eNRR_Succeeded)
347 {
348 NetLog("Name resolution for '%s' failed - binding to 0.0.0.0", address);
349 }
350 else
351 {
352 addr = addrs[0];
353 }
354#endif
355}
356
357void CSimpleHttpServerInternal::Start(uint16 port, string password)
358{

Callers

nothing calls this directly

Calls 9

SIPv4AddrClass · 0.85
cry_sprintfFunction · 0.85
strlenFunction · 0.85
NetLogFunction · 0.85
RequestNameLookupMethod · 0.80
GetCVarMethod · 0.45
GetStringMethod · 0.45
WaitMethod · 0.45
GetResultMethod · 0.45

Tested by

no test coverage detected