| 1153 | } |
| 1154 | |
| 1155 | void Net::process() |
| 1156 | { |
| 1157 | // Process listening sockets |
| 1158 | processListenSocket(PlatformNetState::udpSocket); |
| 1159 | processListenSocket(PlatformNetState::udp6Socket); |
| 1160 | |
| 1161 | // process the polled sockets. This blob of code performs functions |
| 1162 | // similar to WinsockProc in winNet.cc |
| 1163 | |
| 1164 | if (gPolledSockets.size() == 0) |
| 1165 | return; |
| 1166 | |
| 1167 | S32 optval; |
| 1168 | socklen_t optlen = sizeof(S32); |
| 1169 | S32 bytesRead; |
| 1170 | Net::Error err; |
| 1171 | bool removeSock = false; |
| 1172 | PolledSocket *currentSock = NULL; |
| 1173 | NetSocket incomingHandleFd = NetSocket::INVALID; |
| 1174 | NetAddress out_h_addr; |
| 1175 | S32 out_h_length = 0; |
| 1176 | RawData readBuff; |
| 1177 | NetSocket removeSockHandle; |
| 1178 | |
| 1179 | for (S32 i = 0; i < gPolledSockets.size(); |
| 1180 | /* no increment, this is done at end of loop body */) |
| 1181 | { |
| 1182 | removeSock = false; |
| 1183 | currentSock = gPolledSockets[i]; |
| 1184 | |
| 1185 | // Cleanup if we've removed it |
| 1186 | if (currentSock == NULL) |
| 1187 | { |
| 1188 | gPolledSockets.erase(i); |
| 1189 | continue; |
| 1190 | } |
| 1191 | |
| 1192 | switch (currentSock->state) |
| 1193 | { |
| 1194 | case PolledSocket::InvalidState: |
| 1195 | Con::errorf("Error, InvalidState socket in polled sockets list"); |
| 1196 | break; |
| 1197 | case PolledSocket::ConnectionPending: |
| 1198 | // see if it is now connected |
| 1199 | #ifdef TORQUE_OS_XENON |
| 1200 | // WSASetLastError has no return value, however part of the SO_ERROR behavior |
| 1201 | // is to clear the last error, so this needs to be done here. |
| 1202 | if( ( optval = _getLastErrorAndClear() ) == -1 ) |
| 1203 | #else |
| 1204 | if (getsockopt(currentSock->fd, SOL_SOCKET, SO_ERROR, |
| 1205 | (char*)&optval, &optlen) == -1) |
| 1206 | #endif |
| 1207 | { |
| 1208 | Con::errorf("Error getting socket options: %s", strerror(errno)); |
| 1209 | |
| 1210 | removeSock = true; |
| 1211 | removeSockHandle = currentSock->handleFd; |
| 1212 |
nothing calls this directly
no test coverage detected