| 194 | } |
| 195 | |
| 196 | int ServerSocket::get_connection_socket(const string& id) |
| 197 | { |
| 198 | data_signal.lock(); |
| 199 | if (used.find(id) != used.end()) |
| 200 | { |
| 201 | stringstream ss; |
| 202 | ss << "Connection id " << hex << id << " already used"; |
| 203 | throw IO_Error(ss.str()); |
| 204 | } |
| 205 | |
| 206 | while (clients.find(id) == clients.end()) |
| 207 | { |
| 208 | if (data_signal.wait(CONNECTION_TIMEOUT) == ETIMEDOUT) |
| 209 | exit_error("Timed out waiting for peer. See " |
| 210 | "https://mp-spdz.readthedocs.io/en/latest/networking.html " |
| 211 | "for details on networking."); |
| 212 | } |
| 213 | |
| 214 | int client_socket = clients[id]; |
| 215 | used.insert(id); |
| 216 | data_signal.unlock(); |
| 217 | return client_socket; |
| 218 | } |
| 219 | |
| 220 | void* anonymous_accept_thread(void* server_socket) |
| 221 | { |