#pragma once #include /** # UDPpacketVBuffer Create your `UDPsocket` somewhere: UDPsocket sock; ... You have a buffer: FileIO f (path, "r"); std::string buf = f.ReadToString (); Allocate a setup packet and set `len` to your MTU, set your destination `address`, and the destination `channel`. I'm not sure -1 will work as a channel, be sure to set it to your active channel. UDPpacket* packet = SDL_AllocPacket (buf.length ()); packet->len = DEFAULT_MAX_PACKET_SIZE; packet->channel = -1; packet->address = GetPeerAddress (sock, packet->channel); Use `UDPpacketVBuffer` wrapper to send the data, the destructor will automatically free the `UDPpacket**`: UDPpacketVBuffer packetV (&buf[0], buf.length ()); packetV.Send (sock); Then free the leftover setup packet: SDLNet_FreePacket (packet); */ class UDPpacketVBuffer { int npackets; UDPpacket** packetV; public: UDPpacketVBuffer (UDPpacket* src, const void* buf, const size_t size); ~UDPpacketVBuffer (void) { if (packetV) { SDLNet_FreePacketV (packetV); packetV = NULL; } } int Send (UDPsocket sock) { int numsent = 0; if (packetV) { numsent = SDLNet_UDP_SendV (sock, packetV, npackets); } return numsent; } };