MCPcopy Create free account
hub / github.com/GarageGames/Torque2D / activate

Method activate

engine/source/platform/platformNet.cpp:441–478  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

439}
440
441template<class T> T ReservedSocketList<T>::activate(NetSocket socketToActivate, int family, bool useUDP, bool clearOnFail)
442{
443 MutexHandle h;
444 h.lock(mMutex, true);
445
446 int typeID = useUDP ? SOCK_DGRAM : SOCK_STREAM;
447 int protocol = useUDP ? PlatformNetState::getDefaultGameProtocol() : 0;
448
449 if ((U32)socketToActivate.getHandle() >= (U32)mSocketList.size())
450 return -1;
451
452 EntryType &entry = mSocketList[socketToActivate.getHandle()];
453 if (!entry.used)
454 return -1;
455
456 T socketFd = entry.value;
457 if (socketFd == -1)
458 {
459 socketFd = ::socket(family, typeID, protocol);
460
461 if (socketFd == InvalidSocketHandle)
462 {
463 if (clearOnFail)
464 {
465 remove(socketToActivate, false);
466 }
467 return InvalidSocketHandle;
468 }
469 else
470 {
471 entry.used = true;
472 entry.value = socketFd;
473 return socketFd;
474 }
475 }
476
477 return socketFd;
478}
479
480template<class T> T ReservedSocketList<T>::resolve(NetSocket socketToResolve)
481{

Callers 7

setDeviceMethod · 0.45
reactivateMethod · 0.45
openListenPortMethod · 0.45
openConnectToMethod · 0.45
processMethod · 0.45
connectMethod · 0.45
bindAddressMethod · 0.45

Calls 5

getDefaultGameProtocolFunction · 0.85
removeFunction · 0.85
getHandleMethod · 0.80
lockMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected