| 147 | } |
| 148 | |
| 149 | int ASNetwork::SocketTCPSend(SocketID socket, const uint8_t* buf, size_t len) { |
| 150 | std::map<SocketID, SocketData>::iterator datait = sockets.find(socket); |
| 151 | if (datait != sockets.end()) { |
| 152 | SocketData& sd = datait->second; |
| 153 | int ret_data_size = SDLNet_TCP_Send(sd.socket, buf, len); |
| 154 | if (ret_data_size < (int)len) { |
| 155 | sd.valid = false; |
| 156 | DestroySocketTCP(socket); |
| 157 | LOGE << "Error when trying to send data on socket, error: \"" << SDLNet_GetError() << "\", shutting it down." << std::endl; |
| 158 | } |
| 159 | return ret_data_size; |
| 160 | } else { |
| 161 | LOGE << "unable to send data, no such socket " << socket << std::endl; |
| 162 | return -1; |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | bool ASNetwork::IsValidSocketTCP(SocketID socket) { |
| 167 | std::map<SocketID, SocketData>::iterator datait = sockets.find(socket); |
no test coverage detected