You don't actually need to create a new buffer here, you can just assign either global.sendBuffer or global.serverSocket to packetBuffer.