Pages: [1]   Go Down
Author Topic: UDP correct way to Write...  (Read 503 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 69
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


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

like this:
Code:
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:

 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
Logged


Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5145
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: