Ethernet UDP is impossible to make work

I have spent a whole week of wasted time on this. I cannot get anything that even slightly mentions Udp to compile. multiple conflicting errors. I have determined that everything out there is out of date and misleading. I have determined that there are no useable correct examples of a compilable program in existence. All I want to do is have two arduinos swap a UDP packet when requested. I have read that the include xxxxx.Udp is no longer required for 1.8.10 of the IDE. So I do not have an include for it. That is good because I cannot find one anyway and do not know how to add things to the library anyway. I am using a Mega board and an ethernet shield, or i will be if I can ever get anything to compile. I have the Ethernet UDP Udp statement in the program but not sure if it is need or what it is or if I have it in the right place. Everytime I have a Udpxxxxx statement I get a compile error saying the it has been replaced with EthernetUDP and when I put that in then it fails agains saying it is not included. Assume I know nothing about C because even though I have over 25 of these arduinos running just fine I have never used strings or Ethernet before.

Nice vent. Feel better?


Welcome to the Arduino fora.

Assuming you do actually want help rather than to just vent then you need to provide some information so people have something to go on to offer help.

Before you do anything else please take a moment to read General guidance
And How to use this forum
Especially item #7 on posting code.

If you DID just want to vent, then "you're welcome" :slight_smile:

"I have spent a whole week of wasted time on this. "

Just to make you feel better, I can't get UDP to work with the ESP8266 boards even using the provided "examples".

I did a project using UDP on a whole bunch of 8266s about two years ago. Zero problems. Perhaps they broke something in 1.8.10. I would try backing off to 1.8.9. I've been using it for a long time with no significant problems. UDP is fundamentally very simple.

Ray L.

I have used UDP successfully over an ethernet connection to a router. For what it's worth...

I also have UDP working fine between ESP8266s, works lovely, no real problems.

find an NTP server project, copy what they did. NTP is on UDP port 123.

Since UDP is somewhat invisible compared to typical web TCP communications, I tried the below tutorial code among others to see if I could get to work. I downloaded the “Packet Sender” program to send UDP packets to the server per the tutorial. The server code loads and runs per the bottom serial monitor printout. The serial monitor never indicates any reception of any UDP packet from Packet Sender. I may have tried the same with another server code and the server indicated a connection, but the packet capture part of the code never actuated. I tested sending TCP packets to a web server using Packet Sender and that works. Just trying to find simple “hello world” UDP client/server code that can provide a working example. Can’t find the chicken or egg.


#include <ESP8266WiFi.h>
#include <WiFiUdp.h>

const char* ssid = "ARRIS-D1FA";
const char* password = "xxx9AD600186";

WiFiUDP Udp;
unsigned int localUdpPort = 4210;  // local port to listen on
char incomingPacket[255];  // buffer for incoming packets
char  replyPacket[] = "Hi there! Got the message :-)";  // a reply string to send back

void setup()
  Serial.println("Read the Docs");

  Serial.printf("Connecting to %s ", ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED)
  Serial.println(" connected");

  Serial.printf("Now listening at IP %s, UDP port %d\n", WiFi.localIP().toString().c_str(), localUdpPort);

void loop()
  int packetSize = Udp.parsePacket();
  if (packetSize)
    // receive incoming UDP packets
    Serial.printf("Received %d bytes from %s, port %d\n", packetSize, Udp.remoteIP().toString().c_str(), Udp.remotePort());
    int len =, 255);
    if (len > 0)
      incomingPacket[len] = 0;
    Serial.printf("UDP packet contents: %s\n", incomingPacket);

    // send back a reply, to the IP address and port we got the packet from
    Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
Read the Docs

Connecting to ARRIS-D1FA . connected
Now listening at IP, UDP port 4210