void Socket::sendPacket(const net::Packet& packet){ uint32_t payloadSize = packet.getPayload().getCapacity(); // send payload size sendBfr(&payloadSize, sizeof(uint32_t)); // send the actual data sendBfr(packet.getPayload().getData(), packet.getPayload().getCapacity()); }
void Socket::recvPacket(net::Packet& packet){ uint32_t payloadSize = 0; // recieve payload size recvBfr(&payloadSize, sizeof(uint32_t)); // initialize payload memory packet.clear(); packet.getPayload().grow(payloadSize); recvBfr(packet.getPayload().getData(), packet.getPayload().getCapacity()); }