| 1113 | } |
| 1114 | |
| 1115 | void 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); |
nothing calls this directly
no test coverage detected