Issue while using EthernetUdp.h

Hi,
I am new user to arduino, I am using Ethernet Sheild by arduino and mega2560. I simply want to communicate using Udp but i am not able to do so. I am sending msg using arduino ethernet sheild and matlab to receive data packets. I tried the UdpSend Receive code but couldn't succeeded. I am waiting for someone to guide me.

Regards,
Sherazi

That example sketch is misnamed. It actually should be UDPReceiveSend. It sends a UDP packet to a device that first sends a packet to it. It does nothing if it doesn't receive a packet first.

Insure the network settings you are using in that sketch are correct.

Hi,
I used the example code of UDPSendReceiveString. Its a built in example in Arduino 1.0.5.
In this example the;
IP Address (of arduino) = 192.168.1.177 & Mac [] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED} & Local Port = 8888
According to this IP address (of arduino) i changed my PC (Personal Computer) IP address = 192.168.1.180 with Local Port = 8889

I am also attaching my Matlab M file for your convenience and the above mentioned example too. I also want to know whether to use straight cable or cross cable between my PC (Personal Computer) and Ethernet Shield.One more thing that i want to tell you that, I am found #include <EthernetUdp.h> is not working because I checked my doubt by //#include <EthernetUdp.h> and then i compiled the same code but got no error at all even though made to comment that header file. Then i checked the library folder of arduino 1.0.5 but i found the both EthernetUdp.cpp & EthernetUdp.h files there. Now, I am desperately waiting for your reply. I am also thankful for replying my post.

Regards,
Sherazi

UDPSendReceiveString.ino (2.99 KB)

Ethernet_Comm.m (117 Bytes)

I don't use matlab, but here is a previous post that has both the Arduino and Linux C code.
http://forum.arduino.cc/index.php?topic=198259.msg1462983#msg1462983
I reversed the code so the Arduino sends a packet and receives a response packet, and the PC receives the packet, then sends a reply packet. That is how NTP and DNS works. I found this to be more useful because the UDP response packets from the PC to the Arduino will route through a router without any type of mods to the router setup.