I'm trying to conect an Intel Galileo over ethernet. I'm using the code located in Examples/Ethernet/UDPSendReceiveString. Everything works fine except for the response. Udp.remoteIP() always return and Udp.remotePort() always return 0. If I set the IP and port manually instead everything works ok.

My host pc has a windows 10 OS. I've also checked with wireshark that every ip and port is ok.

Arduino code:

#include <SPI.h>         // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include <EthernetUdp.h>         // UDP library from: bjoern@cs.stanford.edu 12/30/2008

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
IPAddress ip(192, 168, 1, 177);

unsigned int localPort = 8888;      // local port to listen on

// buffers for receiving and sending data
char packetBuffer[UDP_TX_PACKET_MAX_SIZE];  //buffer to hold incoming packet,
char  ReplyBuffer[] = "acknowledged";       // a string to send back

// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;

void setup() {
  // start the Ethernet and UDP:
  Ethernet.begin(mac, ip);


void loop() {
  // if there's data available, read a packet
  int packetSize = Udp.parsePacket();
  if (packetSize) {
    Serial.print("Received packet of size ");
    Serial.print("From ");
    IPAddress remote = Udp.remoteIP();
    for (int i = 0; i < 4; i++) {
      Serial.print(remote[i], DEC);
      if (i < 3) {
    Serial.print(", port ");

    // read the packet into packetBufffer
    Udp.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);

    // send a reply to the IP address and port that sent us the packet we received
    Udp.beginPacket(Udp.remoteIP(), Udp.remotePort()); <- there is the fail

Processing code:

 // Processing UDP example to send and receive string data from Arduino
 // press any key to send the "Hello Arduino" message

 import hypermedia.net.*;

 UDP udp;  // define the UDP object

 void setup() {
     udp = new UDP( this, 6000 );  // create a new datagram connection on port 6000
     //udp.log( true );         // <-- printout the connection activity
     udp.listen( true );           // and wait for incoming message

 void draw()

 void keyPressed() {
     String ip       = ""; // the remote IP address
     int port        = 8888;        // the destination port

     udp.send("Hello World", ip, port );   // the message to send


 void receive( byte[] data ) {          // <-- default handler
 //void receive( byte[] data, String ip, int port ) {   // <-- extended handler

     for(int i=0; i < data.length; i++)
  • Assuming you source machine isn't using that address it indicates there is something 'wrong' with the way you are sending the packet to the Galileo. Is you host machine using IPv4 on its primary network interface? – Code Gorilla Jul 25 '16 at 10:09
  • Yes, my host machine is using IPv4 on its primary if. Also I am sending the package from a windows machine, I'll add it to the description. – Jose Jul 25 '16 at 10:23
  • When you say 'If I set the IP and port manually instead everything works ok.' do you mean on the Galileo rather than let it use DHCP? – Code Gorilla Jul 25 '16 at 10:29
  • I mean in the code, If I use the line Udp.beginPacket(Udp.remoteIP(), Udp.remotePort()); it does not work, but If I use the line Udp.beginPacket(windowsIp, 8888); it works ok. – Jose Jul 25 '16 at 10:34
  • I've also checked with wireshark that the ip's are correct. – Jose Jul 25 '16 at 10:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.