Go Down

Topic: UDP correct way to Write... (Read 542 times) previous topic - next topic

buton


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

like this:
Code: [Select]

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

Code: [Select]


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
visit www.diveduino.com

pylon

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.

Go Up