A new object oriented network api that can be used to replace the one provided by the EthernetInterface library.

Dependents:   NetRelais TCP_Client_Example TCP_Server_Example UDP_Server_Example ... more

Object oriented network interface for the mbed platform

Currently implemented:

  • Address
  • Endpoint
  • UDP Socket
  • TCP Socket
  • Databuffer
  • Select API

It depends on the EthernetInterface for the lwip network stack.

Please do not hesitate to contact me with any remarks, improvements or questions.

The API is also available for unix at GitHub: LibNosa

Examples

Revision:
4:d854fa394f85
Parent:
3:d30db8752485
Child:
7:9796742904fa
--- a/buffer.hpp	Wed Jul 18 11:22:37 2012 +0000
+++ b/buffer.hpp	Wed Jul 18 13:20:32 2012 +0000
@@ -26,31 +26,41 @@
 #ifndef _NETWORK_BUFFER_HPP_
 #define _NETWORK_BUFFER_HPP_
 
-#include "
+#include <stdlib.h>
+#include <cstring>
 
-namespace network {
-
+namespace network
+{
     class Buffer
     {
         protected:
-            unsigned char *_memory;
-            size_t _bytes_allocated;
-            size_t _bytes_used;
+            void *_memory;
+            size_t _size;
+            size_t _length;
             
         public:
             Buffer();
+            explicit Buffer(const Buffer &other);
             explicit Buffer(const size_t size);
         
             ~Buffer();
             
-            int read(void *data, size_t max_length);
-            int write(const void *data, size_t length);
+            int read(void *data, size_t max_length, size_t offset = 0);
+            int write(const void *data, size_t length, size_t offset = 0);
+            
+            void *pointer(size_t offset = 0);
+            void setLength(size_t length);
             
-            void *getPointer(bool offset = false);
+            size_t size();
+            size_t length();
+            size_t free();
             
-            size_t getUsed();
-            size_t getFree();
-            size_t getTotal();
+            Buffer &operator=(const Buffer &other);
+       
+       protected:
+            int _memory_allocate(size_t size);
+            void _memory_free();
+            
     };
 
 } // namespace network