*guttural scream*
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user