Hello, I am trying to send two different UDP packets from my Arduino to a PC. That is, I open an UDP port on my Arduino and try to send two strings ("ack1" and "ack2") to two different UDP ports on a PC. I tried in several way, but I just can't do it! On the PC side I read on both ports the same message: "ack2". Message "ack1" is never seen.
I would like to ask if someone knows this issue and if is it possible to bypass it in some way. :~
Thanks a lot
Test code follows:
byte mac[] = { 0x90,0xA2,0xDA,0x00,0x4E,0x22 };
IPAddress ip(10,0,0,2);
IPAddress remoteip(10,0,0,1);
unsigned int localPort = 8888; // local port to listen on
char packetBuffer[UDP_TX_PACKET_MAX_SIZE];
char ReplyBuffer[] = "ack1";
char ReplyBuffer2[] = "ack2";
EthernetUDP Udp;
void setup(){
Ethernet.begin(mac,ip);
Udp.begin(localPort);
}
void loop(){
Udp.beginPacket(remoteip,9000 );
Udp.write(ReplyBuffer);
Udp.endPacket();
delay(1000);
Udp.beginPacket(remoteip,9001 );
Udp.write(ReplyBuffer2);
Udp.endPacket();
delay(1000);
}