WiFi UDP Send and Receive String Library Bug (need guidance)

I am trying to figure out how to use the pre-loaded example WiFi UDP Send and Receive String

/*
  WiFi UDP Send and Receive String

 This sketch wait an UDP packet on localPort using a WiFi shield.
 When a packet is received an Acknowledge packet is sent to the client on port remotePort

 Circuit:
 * WiFi shield attached

 created 30 December 2012
 by dlf (Metodo2 srl)

 */


#include <SPI.h>
#include <WiFi.h>
#include <WiFiUdp.h>

int status = WL_IDLE_STATUS;
 char ssid[] = "yourNetwork";     //  your network SSID (name)
 char pass[] = "secretPassword";   // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0;            // your network key Index number (needed only for WEP)

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

char packetBuffer[255]; //buffer to hold incoming packet
char  ReplyBuffer[] = "acknowledged";       // a string to send back

WiFiUDP Udp;

void setup() {
  //Initialize serial and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue:
    while (true);
  }

  String fv = WiFi.firmwareVersion();
  if ( fv != "1.1.0" )
    Serial.println("Please upgrade the firmware");

  // attempt to connect to Wifi network:
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid);

    // wait 10 seconds for connection:
    delay(10000);
  }
  Serial.println("Connected to wifi");
  printWifiStatus();

  Serial.println("\nStarting connection to server...");
  // if you get a connection, report back via serial:
  Udp.begin(localPort);
}

void loop() {

  // if there's data available, read a packet
  int packetSize = Udp.parsePacket();
  if (packetSize)
  {
    Serial.print("Received packet of size ");
    Serial.println(packetSize);
    Serial.print("From ");
    IPAddress remoteIp = Udp.remoteIP();
    Serial.print(remoteIp);
    Serial.print(", port ");
    Serial.println(Udp.remotePort());

    // read the packet into packetBufffer
    int len = Udp.read(packetBuffer, 255);
    if (len > 0) packetBuffer[len] = 0;
    Serial.println("Contents:");
    Serial.println(packetBuffer);

    // send a reply, to the IP address and port that sent us the packet we received
    Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
    Udp.write(ReplyBuffer);
    Udp.endPacket();
  }
}


void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

I am new to programming, but have identified one mistake in the preloaded code.

// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid);

To my understanding this should be

// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);

I don’t really understand what Receive String is supposed to do, but it gets hung up on

Serial.println("\nStarting connection to server…");
// if you get a connection, report back via serial:
Udp.begin(localPort);

I noticed in the begging of the code that WiFi wasn’t highlighted

WiFiUDP Udp;

Where as in all of the coding I have tinkered with to this point list it as

WiFiServer server(80);

Where the WiFi is orange. Can someone lead me in the direction so the library example will work, so I can start to tinker with Send and Receive String commands?

I think the WiFi Chat Server library example may need corrections as well. It will connect and will Serial.print the ip address, but when I type in the ip address to a webbrower it says “unable to connect” where as in the other examples (web client, web server, and simple web server) it connects.

You are correct about connecting to a wifi network. The example should have had both ssid and pass in the WiFi.begin() call.

Are you certain it is hanging up there? Or is it starting the UDP socket? Udp.begin() returns a value indicating success (1) or fail (0). Modify the begin to this:

Serial.println("\nStarting connection to server...");
  // if you get a connection, report back via serial:
  if(Udp.begin(localPort) == 1) Serial.println("started");
  else Serial.println("failed");

The sketch waits for a UDP packet, then sends a response. My experience with the wifi shield has shown it is not very good at this. It will send the response packet from a different port than the packet was originally sent to, causing a problem on the sending end.

Thanks,

I am not certain it is getting hung up there. The serial monitor said "starting connection to server..." and nothing else ever happened. Reading the code, I identified that's where the "starting connection to server" came from, therefor it seemed like the most likely place the code was getting hung.

Again, this is my first time using UDP socket, I bought two arduino start up books, but neither had any examples using UDP.

When I modified the sketch as you suggested the serial port now reads

Starting connection to server... started


I am trying to get both Arduino Uno/WIFI systems talking through a wifi hotspot (infrastructure mode) or directly (ad hoc mode).

Once I have gotten the two Arduino systems wirelessly communicating then I should get an input signal on system one (button switch on system 1) to show up as an output signal (LED on output on system 2)on the second system with both systems only connected via WIFI.

Send and Receive String sounds like it may be the direction I need to go to accomplish this. If it is not, could someone lead me in the direction that I need to research?

Forget an ad-hoc connection. The wifi shield will not work in that configuration. They must use a wireless router to access each other.

If you want a good example of a UDP "client", take a look at the WiFiUdpNtpClient example sketch. It works good.

Like I said before, the UDP "server" (WiFiUdpSendReceiveString) doesn't work nearly as well.

So if I wanted for the arduinos to be capable of communicating wirelessly to each other even if a router is not present, then I would need a Bluetooth, or x bee shield? Do you have any recommendation on which one would be best?

Can master slave programming work wirelessly? Every example I have seen so far, master slave are connected through wires…

I am still trying to understand the logic behind UpD

I have three questions/ request:

  1. Can someone show me how to translate the following code below that is written for processing to be used on arduino? I want to be able to use two arduinos to talk to each other, without using processing. - This is directly from the sketch UDP send and receive in the Ethernet library.
 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       = "192.168.1.177";	// 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++) 
 print(char(data[i]));  
 println();   
 }
  1. In the Ethernet Library UDPNtP will someone please explain the general concept of how the following code works?
    //the timestamp starts at byte 40 of the received packet and is four bytes,
    // or two words, long. First, esxtract the two words:

    unsigned long highWord = word(packetBuffer[40], packetBuffer[41]);
    unsigned long lowWord = word(packetBuffer[42], packetBuffer[43]);  
    // combine the four bytes (two words) into a long integer
    // this is NTP time (seconds since Jan 1 1900):
    unsigned long secsSince1900 = highWord << 16 | lowWord;  
    Serial.print("Seconds since Jan 1 1900 = " );
    Serial.println(secsSince1900);

I’ll tell you what I’ve tried.
Serial print (packetBuffer[40]) gives 216
Serial print (packetBuffer[41]) gives 29
Serial print (packetBuffer[42]) gives 9
Serial print (packetBuffer[43]) gives 153
Serial print (highWord) gives 55325
Serial print (lowWord) gives 2452
Serial.println(secsSince1900) gives 3625781663
Now I when I add 216 and 29 together it gives 245 which I’m going to go out on a limb and say I probably wasn’t on the right path. When I multiply them I get 6264 However that is supposed to equal highword which is 55325

When i multiply highWord times lowWord I get 135656900 which is still off. I know || means “or” but I do not know what | means. I tried to look it up. I also know a single < means less than, but I don’t know what << means.

Does anyone know of any good tutorials that provides a good hands on learning experience of these concepts?

The HIWORD is (216 * 256) + 29 = 55325
The LOWORD is (9 * 256) + 153 = 2457

The secSince1900 is (55325 * 65536) + 2457 = 3625781657

The “<<” is shift left.

This is starting to come together. Thanks Tim!

So now, I just need to figure out previous questions 1&3 and

  1. where 256 comes from. I know 256 is the highest encryption level bit, but lower bits are available. Does arduino always use the 256 encryption level bits or is there a reference in the coding that will tell you which one is used in the program?

I see 65536 is (256^2)

I don’t understand this line

unsigned long secsSince1900 = highWord << 16 | lowWord;

If it said

unsigned long secsSince1900 = highWord, lowWord);

I could comprehend it. But the << “shift left” seems like it would equal 10^-16. Am I on the right track?

  1. In number 5 what does the “|” mean that I highlighted green?

256 = 2^8
65536 = 2^16

I could comprehend it. But the << “shift left” seems like it would equal 10^-16. Am I on the right track?

This is binary, not decimal. Shift left (<<) is multiply by two. Shift right (>>) is divide by two. It would equal 2^16, not 10^16.

Oh!!!!!! :)

So if I wanted to transmit 3625781657 by putting it into packet buffer blocks first. How would I go by doing that?

Decimal 3625781657 is hex 0xD81D0999 Sometimes it's easier to look at the data in that format, makes it easy to see you are dealing with an unsigned long, which is 4 bytes of data: D8 1D 09 99

Time related elements are all unsigned long data types.

LOWORD and HIWORD to split long into int. LOBYTE and HIBYTE for int to byte.

LOWORD and HIWORD to split long into int. LOBYTE and HIBYTE for int to byte.

Ok so the code would look like this?

3625781657 = LOWORD && HIWORD; LOWORD = LOBYTE && HIBYTE; HIWORD = LOBYTE && HIBYTE';

Decimal 3625781657 is hex 0xD81D0999 Sometimes it's easier to look at the data in that format, makes it easy to see you are dealing with an unsigned long, which is 4 bytes of data: D8 1D 09 99

I am trying to get two arduinos to talk to each other using WiFi. When Button 1 on Ardunio1 is pressed I want led 2 on Arduino2 to come on. Right now I only have half of a working example to go on. (The NTP example). It only shows half of the example that I need for both parts to work. Decimal might be easier, but I don't have a working code example to go from that uses this format. If this is explained in your book with working examples/experiments let me know and I will purchase it. I have two arduino starter books, but neither explains wireless communication TCP/UDP protocols using arduino examples, which is a shame because that's how you make the really cool stuff work!

You might start developing your communication code using a wired connection between the arduinos. When that works then being in the wireless adapters.

Ok. I will take your advice and plan to have this completed by today.

My code so far (Master)

boolean RunForTheHills = 0;
#include <Wire.h>

void setup()
{
  pinMode(2,INPUT); // ledOn Switch
  pinMode(3,INPUT); // ledOff Switch
  pinMode(4,OUTPUT);// led 
  Wire.begin(); // join i2c bus (address optional for master)
}

byte x = 0;

void loop()
{
  Switch1 ();
  Switch2();
  LedStatus();
}

  void Switch1 (){ 
    if (digitalRead(2) == HIGH)  // on Switch
    { RunForTheHills = HIGH;     // led on arduino 1 
      Wire.beginTransmission(4); // transmit to device #4
      Wire.write("led4,HIGH ");  // sends five bytes
      Wire.write(x);             // sends one byte  
      Wire.endTransmission();    // stop transmitting
      delay(500);
    }
  }
  
  
  void Switch2() {
    if (digitalRead(3) == HIGH)  // off switch
    { RunForTheHills = LOW;      // led on arduino 1
      Wire.beginTransmission(4); // transmit to device #4
      Wire.write("led4,LOW ");   // sends five bytes
      Wire.write(x);             // sends one byte  
      Wire.endTransmission();    // stop transmitting
      delay(500);
    }
  }
  
  void LedStatus(){
    if (RunForTheHills == HIGH)
    { digitalWrite(4,HIGH);
    } else { digitalWrite(4,LOW);
           }
  }

My code for the slave (I don’t understand why the lines followed by /////////////////are not acceptable)

boolean RunForTheHills = 0;

#include <Wire.h>

void setup()
{
  Wire.begin(4);                // join i2c bus with address #4
  Wire.onReceive(receiveEvent); // register event
  Serial.begin(9600);           // start serial for output
}

void loop()
{
  delay(100);
  pinMode(4,OUTPUT);
}

// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany)
{
  while(1 < Wire.available()) // loop through all but the last
  {
    char c = Wire.read(); // receive byte as a character
    Serial.print(c);         // print the character
  }
  int x = Wire.read();    // receive byte as an integer
  Serial.println(x);         // print the integer
  if (Wire.read == "led4,HIGH")////////////////////////////////////////////////////////////
  { RunForTheHills = HIGH);
  }
    if (Wire.read == led4,LOW)//////////////////////////////////////////////////////////
  { RunForTheHills = HIGH);
  }
  /*
  if (Wire.read == 0)
  "needs to tell it transmission is over"
  
  */
      if (RunForTheHills == HIGH)
    { digitalWrite(4,HIGH);
    } else { digitalWrite(4,LOW);
           }
  }
}

Am I on the right track?

You might start developing your communication code using a wired connection between the arduinos.

I have the Wire program working as I intended now. I am ashamed that it took me so long to figure it out "I had a little trouble reverse engineering the Serial.untilBuffer(); that the processing app uses in every youTube video I could find.http://arduino.cc/en/Reference/SerialBufferUntil

Apparently this program was never invented as was mentioned in the following post http://forum.arduino.cc/index.php?topic=95486.0
In the end, I got through this hurdle by using the following reference with a little modificationhttp://forum.arduino.cc/index.php/topic,95285.0.html

The official working code that I believe may be of great value to new programers is listed below

Master Program:

boolean RunForTheHills = 0;
#include <Wire.h>

void setup()
{
  pinMode(2,INPUT); // ledOn Switch
  pinMode(3,INPUT); // ledOff Switch
  pinMode(4,OUTPUT);// led 
  Wire.begin(); // join i2c bus (address optional for master)
}

byte x = 0;

void loop()
{
  Switch1 ();
  Switch2();
  LedStatus();
}

  void Switch1 (){ 
    if (digitalRead(2) == HIGH)  // on Switch
    { RunForTheHills = HIGH;     // led on arduino 1 
      Wire.beginTransmission(4); // transmit to device #4
      Wire.write("led4,HIGH. ");  // sends five bytes
      Wire.write(x);             // sends one byte  
      Wire.endTransmission();    // stop transmitting
      delay(500);
    }
  }
  
  
  void Switch2() {
    if (digitalRead(3) == HIGH)  // off switch
    { RunForTheHills = LOW;      // led on arduino 1
      Wire.beginTransmission(4); // transmit to device #4
      Wire.write("led4,LOW. ");   // sends five bytes
      Wire.write(x);             // sends one byte  
      Wire.endTransmission();    // stop transmitting
      delay(500);
    }
  }
  
  void LedStatus()
  { digitalWrite(4,RunForTheHills); }

Slave Program:

String currentLine = "";
boolean RunForTheHills = 0;

#include <Wire.h>
  void setup()
  { Wire.begin(4);                // join i2c bus with address #4
    Wire.onReceive(receiveEvent); // register event
    Serial.begin(9600);           // start serial for output
    pinMode(4,OUTPUT);
  }

  void loop()
  { delay(100);
    LedStatus();
  }
  

  void receiveEvent(int howMany)
  { String currentLine = "";
    while(1 < Wire.available()) // loop through all but the last
    { char c = Wire.read();     // receive byte as a character
      if (c != '.')      
      { currentLine +=c; 
        if (currentLine == "led4,HIGH")
        { RunForTheHills = HIGH; }
        if (currentLine == "led4,LOW")
        { RunForTheHills = LOW; }
      } else {Serial.print(currentLine); 
        currentLine = ""; }
    }
  int x = Wire.read();         // receive byte as an integer
  Serial.println(x);           // print the integer
  }  
  
  void LedStatus()
  { digitalWrite(4,RunForTheHills); }

When that works then being in the wireless adapters

Will someone please help point me in the direction to get this code working through a Wi-Fi connection now?

I would like to thank everyone that volunteers their valuable time to help new programers learn the language. We really appreciate it!

I will send a check a valid check for $25 to the first person that solves this. Or if you prefer set up an ebay or amazon account and i’ll purchase whatever you would like me to for $25 and paypal will take care of the payment transaction. All you should need to figure this out is a Wi-Fi shield, an Arduino, and the processing app.

I need this UpD example to work. I’ve spent two weeks trying to figure out how to make this work, and it just wont! I’m putting a bounty on this.

This code is the part that I think is the issue. It’s pretty much an exact duplicate of the working Ethernet UpD Send and Receive example. I modified it for Wi-Fi. You will have to change char ssid = “yourNetwork”; (name) &&
char pass = “secretPassword”; && IPAddress ip(192, 168, 1, 177); to meet your network requirements

#include <SPI.h>
#include <WiFi.h>
#include <WiFiUdp.h>

int status = WL_IDLE_STATUS;
  char ssid[] = "yourNetwork"; //  your network SSID (name)
char pass[] = "secretPassword";  // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0;            // your network key Index number (needed only for WEP)
//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

WiFiUDP Udp;

void setup() 

{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue:
    while (true);
  }

  String fv = WiFi.firmwareVersion();
  if ( fv != "1.1.0" )
    Serial.println("Please upgrade the firmware");

  // attempt to connect to Wifi network:
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
    delay(10000);
  }

  Serial.println("Connected to wifi");
  printWifiStatus();

  Serial.println("\nStarting connection to server...");
  Udp.begin(localPort);
}

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

    // read the packet into packetBufffer
    Udp.read(packetBuffer,UDP_TX_PACKET_MAX_SIZE);
    Serial.println("Contents:");
    Serial.println(packetBuffer);

    // send a reply, to the IP address and port that sent us the packet we received
    Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
    Udp.write(ReplyBuffer);
    Udp.endPacket();
  }
  delay(10);
}

void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  //IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

Here is a copy of the Ethernet version that is working for me. You will have to change IPAddress ip(192, 168, 1, 177); to meet your network requirements

#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);
  Udp.begin(localPort);

  Serial.begin(9600);
}

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

    // read the packet into packetBufffer
    Udp.read(packetBuffer,UDP_TX_PACKET_MAX_SIZE);
    Serial.println("Contents:");
    Serial.println(packetBuffer);

    // send a reply, to the IP address and port that sent us the packet we received
    Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
    Udp.write(ReplyBuffer);
    Udp.endPacket();
  }
  delay(10);
}

Here is the processing app. You will have to change String ip =(192, 168, 1, 177); to meet your network requirements

 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       = "192.168.1.177";	// 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++) 
 print(char(data[i]));  
 println();   
 }

I’ve never been so frustrated in my life. These two are written nearly identical except for the modification to use WiFi over internet. I don’t understand why when written to the best of my understanding “identical” the Ethernet Version works, but the Wi-Fi version won’t. The library example UpDNtP works with the WiFi shield. It just doesn’t make sense why this one won’t.

The ethernet version returns the packet from the same port as the sender sent it to. In you case the processing sends the packet to port 8888 on the ethernet shield, and the ethernet shield returns the packet from port 8888.

The wifi version does not. The processing program will send the packet to port 8888 on the wifi shield, and the wifi shield receives it, but the packet returned from the wifi shield will not be from port 8888. It is something buggy in the wifi firmware.

edit: The WiFiUdpNtp code sends a packet (but not from the port you expected), then gets a response. Your code receives a packet and sends a response. The wifi shield fails in that respect. Your computer's connection tracking is expecting a response from 192.168.1.177 port 8888 within 10 seconds, or the tracking stops. Since the response packet is not from port 8888, the tracking fails.

You can sometimes overcome this by allowing UDP port 8888 destination packets through your computer's firewall.

The processing program will send the packet to port 8888 on the wifi shield, and the wifi shield receives it

Shouldn't the WiFi arduino still receive the "Hello World" signal from the processing app

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

and in turn print the message off in Serial? For some reason I can't get mine to even do that.

but the packet returned from the wifi shield will not be from port 8888

I did notice this in my debugging efforts. I wasn't sure why that was happening.

I need the code that I posted in post #15 to allow the two arduinos to talk to each other over a WiFi connection. Is it necessary to use the port code for this kind of implementation, or can it be by-pass similar to how the WiFi Server and WiFi client program examples works? Or can someone think of different way to look into that might be more ideal to achieve the results I need?

Are you certain your processing program is sending the packet? I have my programs the other way around. I have the wifi shields send and receive like the WifiUdpNtpClient code. The processing is the "server".

edit: Here is a thread that has my code for the ethernet shield and a Linux box. http://forum.arduino.cc/index.php?topic=198259.msg1462983#msg1462983