UDP correct way to Write...

So i wonder whichone is the correct way to send packets through udp and why

like this:

 for(byte z=0; z<5;z++)
    {
      Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
         Udp.write("sent ");
         itoa(z,stringOne,5);
        Udp.write(stringOne); 
         Udp.endPacket();
      
     
    }

or

 Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
    for(byte z=0; z<5;z++)
    {
     
         Udp.write("sent ");
         itoa(z,stringOne,5);
        Udp.write(stringOne); 
      
      
    
    }
       Udp.endPacket();

thanks

Which one is correct depends on what you like to do. The first code segement sends 5 UDP packets to the remote host, where the second one sends only one packet.