| 1105 | } |
| 1106 | |
| 1107 | void Net::process() |
| 1108 | { |
| 1109 | // Process listening sockets |
| 1110 | processListenSocket(PlatformNetState::udpSocket); |
| 1111 | processListenSocket(PlatformNetState::udp6Socket); |
| 1112 | |
| 1113 | #ifdef TORQUE_NET_CURL |
| 1114 | // process HTTPObject |
| 1115 | HTTPObject::process(); |
| 1116 | #endif |
| 1117 | |
| 1118 | // process the polled sockets. This blob of code performs functions |
| 1119 | // similar to WinsockProc in winNet.cc |
| 1120 | |
| 1121 | if (gPolledSockets.size() == 0) |
| 1122 | return; |
| 1123 | |
| 1124 | S32 optval; |
| 1125 | socklen_t optlen = sizeof(S32); |
| 1126 | S32 bytesRead; |
| 1127 | Net::Error err; |
| 1128 | bool removeSock = false; |
| 1129 | PolledSocket *currentSock = NULL; |
| 1130 | NetSocket incomingHandleFd = NetSocket::INVALID; |
| 1131 | NetAddress out_h_addr; |
| 1132 | S32 out_h_length = 0; |
| 1133 | RawData readBuff; |
| 1134 | NetSocket removeSockHandle; |
| 1135 | |
| 1136 | for (S32 i = 0; i < gPolledSockets.size(); |
| 1137 | /* no increment, this is done at end of loop body */) |
| 1138 | { |
| 1139 | removeSock = false; |
| 1140 | currentSock = gPolledSockets[i]; |
| 1141 | |
| 1142 | // Cleanup if we've removed it |
| 1143 | if (currentSock == NULL) |
| 1144 | { |
| 1145 | gPolledSockets.erase(i); |
| 1146 | continue; |
| 1147 | } |
| 1148 | |
| 1149 | switch (currentSock->state) |
| 1150 | { |
| 1151 | case PolledSocket::InvalidState: |
| 1152 | Con::errorf("Error, InvalidState socket in polled sockets list"); |
| 1153 | break; |
| 1154 | case PolledSocket::ConnectionPending: |
| 1155 | // see if it is now connected |
| 1156 | if (getsockopt(currentSock->fd, SOL_SOCKET, SO_ERROR, |
| 1157 | (char*)&optval, &optlen) == -1) |
| 1158 | { |
| 1159 | Con::errorf("Error getting socket options: %s", strerror(errno)); |
| 1160 | |
| 1161 | removeSock = true; |
| 1162 | removeSockHandle = currentSock->handleFd; |
| 1163 | |
| 1164 | smConnectionNotify->trigger(currentSock->handleFd, Net::ConnectFailed); |
nothing calls this directly
no test coverage detected