Code:
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
#include <NativeEthernet.h>
#include <NativeEthernetUdp.h>
/*
UDPReceiveOSC
Set a tone according to incoming OSC control
Adrian Freed
*/
//UDP communication
EthernetUDP Udp;
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
}; // you can find this written on the board of some Arduino Ethernets or shields
//the Arduino's IP
IPAddress ip(192, 168, 1, 177);
const unsigned int inPort = 8888;
void setup() {
Serial.begin(115200);
while (!Serial);
Ethernet.setStackHeap(1024 * 128);
Ethernet.setSocketSize(16000); //Set buffer size
Ethernet.setSocketNum(2); //Change number of allowed sockets to 2
Ethernet.begin(mac, ip);
Udp.begin(inPort);
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
// Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :(");
while (true) {
delay(1); // do nothing, no point running without Ethernet hardware
}
}
if (Ethernet.linkStatus() == LinkOFF) {
// Serial.println("Ethernet cable is not connected.");
}
Serial.println("UDP server running");
}
void loop() {
int size;
if ( (size = Udp.parsePacket()) > 0)
{
Serial.println("received " + String(size));
}
}
With this code, the outer limits are at 10212 Byte per message. 10214 don't work!