Send all bytes to the socket, handling partial writes.
| 69 | |
| 70 | /// Send all bytes to the socket, handling partial writes. |
| 71 | void sendAllBytes(Poco::Net::StreamSocket & socket, const char * data, size_t len) |
| 72 | { |
| 73 | size_t total = 0; |
| 74 | while (total < len) |
| 75 | { |
| 76 | int sent = socket.sendBytes(data + total, static_cast<int>(len - total)); |
| 77 | if (sent <= 0) |
| 78 | throw Poco::IOException("Failed to send bytes to WebSocket"); |
| 79 | total += static_cast<size_t>(sent); |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | /// Send a WebSocket frame. Server-to-client frames are not masked. |
| 84 | /// Header and payload are combined into a single buffer to avoid partial frame writes. |
no test coverage detected