OK, after looking through all the examples I have, I have realized that the send code came from a Processing Program's C code that runs on a PC to talk with the Ethernet shield EthernetUdp.
Various versions of this Processing Program's C code are at the bottom of most of the Udp examples. No wander it does not work. It took a lot of research just to find out that the Processing example was NOT Adrunio code, but I had already used that snippet before I found that out, because it looked like what I wanted to do.
My Ethernet2 Library came up in the Library manager and was installed from there.
which other Library might you be referring to...?
/**
* (./) udp.pde - how to use UDP library as unicast connection
* (cc) 2006, Cousot stephane for The Atelier Hypermedia
* (->) http://hypermedia.loeil.org/processing/
*
* Create a communication between Processing<->Pure Data @ http://puredata.info/
* This program also requires to run a small program on Pd to exchange data
* (hum!!! for a complete experimentation), you can find the related Pd patch
* at http://hypermedia.loeil.org/processing/udp.pd
*
* -- note that all Pd input/output messages are completed with the characters
* ";\n". Don't refer to this notation for a normal use. --
*/
// import UDP library
//import hypermedia.net.*;
#include <udp.h>
//UDP udp; // define the UDP object
/**
* init
*/
void setup() {
// create a new datagram connection on port 6000
// and wait for incomming message
udp = new UDP( this, 6000 );
//udp.log( true ); // <-- printout the connection activity
udp.listen( true );
}
//process events
void draw() {;}
Different example.......
#include <Esplora.h>
// Processing sketch to run with this example
// =====================================================
/*
Processing sketch to run with this example
=====================================================
// 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 = "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();
}
*/