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

Method process

engine/source/platform/platformNet.cpp:1115–1373  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1113}
1114
1115void Net::process()
1116{
1117 // Process listening sockets
1118 processListenSocket(PlatformNetState::udpSocket);
1119 processListenSocket(PlatformNetState::udp6Socket);
1120
1121 // process the polled sockets. This blob of code performs functions
1122 // similar to WinsockProc in winNet.cc
1123
1124 if (gPolledSockets.size() == 0)
1125 return;
1126
1127 static ConnectedNotifyEvent notifyEvent;
1128 static ConnectedAcceptEvent acceptEvent;
1129 static ConnectedReceiveEvent cReceiveEvent;
1130
1131 S32 optval;
1132 socklen_t optlen = sizeof(S32);
1133 S32 bytesRead;
1134 Net::Error err;
1135 bool removeSock = false;
1136 PolledSocket *currentSock = NULL;
1137 NetSocket incomingHandleFd = NetSocket::INVALID;
1138 NetAddress out_h_addr;
1139 S32 out_h_length = 0;
1140 NetSocket removeSockHandle;
1141
1142 for (S32 i = 0; i < gPolledSockets.size();
1143 /* no increment, this is done at end of loop body */)
1144 {
1145 removeSock = false;
1146 currentSock = gPolledSockets[i];
1147
1148 // Cleanup if we've removed it
1149 if (currentSock == NULL)
1150 {
1151 gPolledSockets.erase(i);
1152 continue;
1153 }
1154
1155 switch (currentSock->state)
1156 {
1157 case PolledSocket::InvalidState:
1158 Con::errorf("Error, InvalidState socket in polled sockets list");
1159 break;
1160 case PolledSocket::ConnectionPending:
1161 // see if it is now connected
1162 if (getsockopt(currentSock->fd, SOL_SOCKET, SO_ERROR,
1163 (char*)&optval, &optlen) == -1)
1164 {
1165 Con::errorf("Error getting socket options: %s", strerror(errno));
1166
1167 removeSock = true;
1168 removeSockHandle = currentSock->handleFd;
1169
1170 notifyEvent.state = ConnectedNotifyEvent::ConnectFailed;
1171 notifyEvent.tag = currentSock->handleFd;
1172 Game->postEvent(notifyEvent);

Callers

nothing calls this directly

Calls 15

errorfFunction · 0.85
netSocketWaitForWritableFunction · 0.85
printfFunction · 0.85
getLastErrorFunction · 0.85
addPolledSocketFunction · 0.85
checkLookupMethod · 0.80
resolveMethod · 0.80
NetAddressToIPSocketFunction · 0.70
IPSocketToNetAddressFunction · 0.70
NetAddressToIPSocket6Function · 0.70
IPSocket6ToNetAddressFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected