UDPSendReceiveString problem

Hi, I am having a problem with the UDPSendReceiveString example. I only modified the ip address in the code. I am using iBoard Ex, which comes with w5100 chip.

In the processing sketch I changed the ip to "255.255.255.255" to send a broadcast message, but arduino serial monitor does not display anything, so I assume it is not receiving any udp message.

When I change the ip in processing to my pc's ip, I get the error message "could not send message. no route to host: datagram send failed".

I have already disabled firewall. Another thing is that my pc has no internet connection. Would appreciate any help. Thanks.

I am using iBoard Ex

Which once again you haven't provided a link to. Get with the program, here.

PaulS:
Which once again you haven’t provided a link to.

Link to iBoard: IBoard Ex - ITEAD Wiki

Code for iBoard:

#include <SPI.h>
#include <Ethernet.h>
#include < EthernetUdp.h >

byte mac[] = {__, __, __, __, __, __}; // MAC address of controller
IPAddress ip (192,168,1,21);               // ip of pc

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

// buffers for receiving and sending data (need to change to send bytes instead of char)
char packetBuffer [UDP_TX_PACKET_MAX_SIZE]; // buffer to hold incoming packet
char replyBuffer[] = “acknowledged”; // a string to send back

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

void setup(){
 Serial.begin(115200);

 Ethernet.begin (mac, ip); // Start Ethernet connection
 Udp.begin (localPort); // Start UDP
}


void loop(){
 // if 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 packetBuffer
 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);
}

Code for processing:

import hypermedia.net.*;	// import the UDP library

UDP udp;		// define the UDP object

void setup(){
	udp = new UDP (this, 43770);		// create a new datagram connection on port 43770
	udp.listen (true);			// and wait for incoming message
}


void draw(){
}


void keyPressed(){
	int destPort = 43770;
	String ip = “255.255.255.255”;			// broadcast message
	udp.send (“Hello World\n”, ip, destPort);		// the message to send
}


void receive (byte[] data){
	// print the incoming data bytes as ASCII characters
	for (int i=0; i<data.length; i++) {
		print (char (data[i]));
	}
	println();
}
byte mac[] = {__, __, __, __, __, __}; // MAC address of controller

Well, I can certainly understand redacting that. NOT.

	udp = new UDP (this, 43770);

new returns a pointer. You MUST store that in a variable of type pointer to.

I haven't tried your code, but my w5100 will receive broadcasts on the localnet broadcast address. On your subnet, that would be 192.168.1.255.

I have found the problem. The code works perfectly.

There was no DNS server set on the connection, so the link keeps breaking. Thanks all for the help.