added readme

This commit is contained in:
Jorijn van der Graaf 2025-11-03 17:52:45 +01:00
commit 5bfee7f955
3 changed files with 147 additions and 22 deletions

View file

@ -95,21 +95,12 @@ void ClientTCP::Stop() {
}
void ClientTCP::Send(const void* buffer, std::uint32_t size) const {
const char* data = reinterpret_cast<const char*>(buffer);
std::uint_fast32_t totalSent = 0;
const std::uint_fast32_t chunkSize = 1024;
int status = send(socketid, reinterpret_cast<const char*>(buffer), size, 0);
while (totalSent < size) {
std::uint_fast32_t bytesToSend = std::min(chunkSize, size - totalSent);
int status = send(socketid, data + totalSent, bytesToSend, 0);
if (status == 0) {
throw SocketClosedException();
} else if (status < 0) {
throw std::runtime_error(std::strerror(errno));
}
totalSent += status;
if (status == 0) {
throw SocketClosedException();
} else if (status < 0) {
throw std::runtime_error(std::strerror(errno));
}
}
std::vector<char> ClientTCP::RecieveSync(std::uint32_t bufferSize) const {