| 456 | } |
| 457 | |
| 458 | static void MPConnection_SendData(const cc_uint8* data, cc_uint32 len) { |
| 459 | cc_uint32 wrote; |
| 460 | cc_result res; |
| 461 | int tries = 0; |
| 462 | if (Server.Disconnected) return; |
| 463 | |
| 464 | while (len) { |
| 465 | res = Socket_Write(net_socket, data, len, &wrote); |
| 466 | /* If sending would block (send buffer full), retry for a bit up to 10 seconds */ |
| 467 | /* TODO: Avoid doing this and manually buffer data when this happens */ |
| 468 | if (res && tries < 1000 && (res == ReturnCode_SocketInProgess || res == ReturnCode_SocketWouldBlock)) { |
| 469 | Thread_Sleep(10); |
| 470 | tries++; |
| 471 | continue; |
| 472 | } |
| 473 | |
| 474 | /* NOTE: Not immediately disconnecting here, as otherwise we sometimes miss out on kick messages */ |
| 475 | if (res) { net_writeFailure = res; return; } |
| 476 | if (!wrote) { net_writeFailure = ERR_INVALID_ARGUMENT; return; } |
| 477 | |
| 478 | data += wrote; len -= wrote; |
| 479 | } |
| 480 | } |
| 481 | |
| 482 | static void MPConnection_Init(void) { |
| 483 | Server_ResetState(); |
nothing calls this directly
no test coverage detected