Go Down

Topic: UDP correct way to Write... (Read 580 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
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy