*guttural scream*

This commit is contained in:
MarcEricMartel
2023-11-01 06:12:38 -04:00
parent 48078182a1
commit 88a8553608
4 changed files with 41 additions and 34 deletions

View File

@@ -183,19 +183,21 @@ namespace netprot {
template <class T>
void sendPack(SOCKET sock, T* pack, Buffer* buf) {
const char footer[sizeof(uint32_t)] = { '\0', '\r', '\0', '\n' };
netprot::Serialize(pack, &buf->ptr, &buf->len);
memset(&buf->ptr[buf->len], '\0', sizeof(uint64_t) + sizeof(uint8_t));
buf->len += sizeof(uint64_t) + sizeof(uint8_t);
memcpy(&buf->ptr[buf->len], footer, sizeof(uint32_t));
buf->len += sizeof(uint32_t);
send(sock, buf->ptr, buf->len, 0);
buf->rstLen();
}
template <class T>
void sendPackTo(SOCKET sock, T* pack, Buffer* buf, sockaddr_in* sockad) {
const char footer[sizeof(uint32_t)] = { '\0', '\r', '\0', '\n' };
sockaddr_in addr = *sockad;
netprot::Serialize(pack, &buf->ptr, &buf->len);
memset(&buf->ptr[buf->len], '\0', sizeof(uint64_t) + sizeof(uint8_t));
buf->len += sizeof(uint64_t) + sizeof(uint8_t);
memcpy(&buf->ptr[buf->len], footer, sizeof(uint32_t));
buf->len += sizeof(uint32_t);
sendto(sock, buf->ptr, buf->len, 0, (sockaddr*)&addr, sizeof(addr));
buf->rstLen();
}