UIPEthernet library for Arduino IDE, Eclipse with arduino plugin and MBED/SMeshStudio (AVR,STM32F,ESP8266,Intel ARC32,Nordic nRF51,Teensy boards,Realtek Ameba(RTL8195A,RTL8710)), ENC28j60 network chip. Compatible with Wiznet W5100 Ethernet library API. Compiled and tested on Nucleo-F302R8. Master repository is: https://github.com/UIPEthernet/UIPEthernet/

Revision:
0:e3fb1267e3c3
Child:
11:3fb19220d9ec
diff -r 000000000000 -r e3fb1267e3c3 examples/TcpServer/TcpServer.ino
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/TcpServer/TcpServer.ino	Wed Dec 21 16:58:10 2016 +0100
@@ -0,0 +1,60 @@
+/*
+ * UIPEthernet EchoServer example.
+ *
+ * UIPEthernet is a TCP/IP stack that can be used with a enc28j60 based
+ * Ethernet-shield.
+ *
+ * UIPEthernet uses the fine uIP stack by Adam Dunkels <adam@sics.se>
+ *
+ *      -----------------
+ *
+ * This Hello World example sets up a server at 192.168.1.6 on port 1000.
+ * Telnet here to access the service.  The uIP stack will also respond to
+ * pings to test if you have successfully established a TCP connection to
+ * the Arduino.
+ *
+ * This example was based upon uIP hello-world by Adam Dunkels <adam@sics.se>
+ * Ported to the Arduino IDE by Adam Nielsen <malvineous@shikadi.net>
+ * Adaption to Enc28J60 by Norbert Truchsess <norbert.truchsess@t-online.de>
+ */
+
+#include <UIPEthernet.h>
+#include "utility/logging.h"
+
+EthernetServer server = EthernetServer(1000);
+
+void setup()
+{
+  #if ACTLOGLEVEL>LOG_NONE
+    LogObject.begin(9600);
+  #endif
+
+  uint8_t mac[6] = {0x00,0x01,0x02,0x03,0x04,0x05};
+  IPAddress myIP(192,168,0,6);
+
+  Ethernet.begin(mac,myIP);
+
+  server.begin();
+}
+
+void loop()
+{
+  size_t size;
+
+  if (EthernetClient client = server.available())
+    {
+      while((size = client.available()) > 0)
+        {
+          uint8_t* msg = (uint8_t*)malloc(size);
+          size = client.read(msg,size);
+          #if ACTLOGLEVEL>=LOG_INFO
+            LogObject.write(msg,size);
+          #endif
+          free(msg);
+        }
+      #if ACTLOGLEVEL>=LOG_INFO
+        LogObject.uart_send_strln(F("DATA from Server!"));
+      #endif
+      client.stop();
+    }
+}