MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / activate

Method activate

Engine/source/platform/platformNet.cpp:397–434  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

395}
396
397template<class T> T ReservedSocketList<T>::activate(NetSocket socketToActivate, int family, bool useUDP, bool clearOnFail)
398{
399 MutexHandle h;
400 h.lock(mMutex, true);
401
402 int typeID = useUDP ? SOCK_DGRAM : SOCK_STREAM;
403 int protocol = useUDP ? PlatformNetState::getDefaultGameProtocol() : 0;
404
405 if ((U32)socketToActivate.getHandle() >= (U32)mSocketList.size())
406 return -1;
407
408 EntryType &entry = mSocketList[socketToActivate.getHandle()];
409 if (!entry.used)
410 return -1;
411
412 T socketFd = entry.value;
413 if (socketFd == -1)
414 {
415 socketFd = ::socket(family, typeID, protocol);
416
417 if (socketFd == InvalidSocketHandle)
418 {
419 if (clearOnFail)
420 {
421 remove(socketToActivate, false);
422 }
423 return InvalidSocketHandle;
424 }
425 else
426 {
427 entry.used = true;
428 entry.value = socketFd;
429 return socketFd;
430 }
431 }
432
433 return socketFd;
434}
435
436template<class T> T ReservedSocketList<T>::resolve(NetSocket socketToResolve)
437{

Callers 5

openListenPortMethod · 0.45
openConnectToMethod · 0.45
processMethod · 0.45
connectMethod · 0.45
bindAddressMethod · 0.45

Calls 4

getDefaultGameProtocolFunction · 0.85
lockMethod · 0.45
getHandleMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected