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

Committer:
NegativeBlack
Date:
Wed Jul 18 11:22:37 2012 +0000
Revision:
3:d30db8752485
Child:
4:d854fa394f85
Implemented UDP and TCP socket. UDP is fully tested, TCP still needs to be tested.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
NegativeBlack 3:d30db8752485 1 /**
NegativeBlack 3:d30db8752485 2 * Copyright (c) 2012, Roy van Dam <roy@vandam-innovations.com>
NegativeBlack 3:d30db8752485 3 * All rights reserved.
NegativeBlack 3:d30db8752485 4 *
NegativeBlack 3:d30db8752485 5 * Redistribution and use in source and binary forms, with or without
NegativeBlack 3:d30db8752485 6 * modification, are permitted provided that the following conditions are met:
NegativeBlack 3:d30db8752485 7 *
NegativeBlack 3:d30db8752485 8 * 1. Redistributions of source code must retain the above copyright notice, this
NegativeBlack 3:d30db8752485 9 * list of conditions and the following disclaimer.
NegativeBlack 3:d30db8752485 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
NegativeBlack 3:d30db8752485 11 * this list of conditions and the following disclaimer in the documentation
NegativeBlack 3:d30db8752485 12 * and/or other materials provided with the distribution.
NegativeBlack 3:d30db8752485 13 *
NegativeBlack 3:d30db8752485 14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
NegativeBlack 3:d30db8752485 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
NegativeBlack 3:d30db8752485 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
NegativeBlack 3:d30db8752485 17 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
NegativeBlack 3:d30db8752485 18 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
NegativeBlack 3:d30db8752485 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
NegativeBlack 3:d30db8752485 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
NegativeBlack 3:d30db8752485 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
NegativeBlack 3:d30db8752485 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
NegativeBlack 3:d30db8752485 23 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
NegativeBlack 3:d30db8752485 24 */
NegativeBlack 3:d30db8752485 25
NegativeBlack 3:d30db8752485 26 #ifndef _NETWORK_BUFFER_HPP_
NegativeBlack 3:d30db8752485 27 #define _NETWORK_BUFFER_HPP_
NegativeBlack 3:d30db8752485 28
NegativeBlack 3:d30db8752485 29 #include "
NegativeBlack 3:d30db8752485 30
NegativeBlack 3:d30db8752485 31 namespace network {
NegativeBlack 3:d30db8752485 32
NegativeBlack 3:d30db8752485 33 class Buffer
NegativeBlack 3:d30db8752485 34 {
NegativeBlack 3:d30db8752485 35 protected:
NegativeBlack 3:d30db8752485 36 unsigned char *_memory;
NegativeBlack 3:d30db8752485 37 size_t _bytes_allocated;
NegativeBlack 3:d30db8752485 38 size_t _bytes_used;
NegativeBlack 3:d30db8752485 39
NegativeBlack 3:d30db8752485 40 public:
NegativeBlack 3:d30db8752485 41 Buffer();
NegativeBlack 3:d30db8752485 42 explicit Buffer(const size_t size);
NegativeBlack 3:d30db8752485 43
NegativeBlack 3:d30db8752485 44 ~Buffer();
NegativeBlack 3:d30db8752485 45
NegativeBlack 3:d30db8752485 46 int read(void *data, size_t max_length);
NegativeBlack 3:d30db8752485 47 int write(const void *data, size_t length);
NegativeBlack 3:d30db8752485 48
NegativeBlack 3:d30db8752485 49 void *getPointer(bool offset = false);
NegativeBlack 3:d30db8752485 50
NegativeBlack 3:d30db8752485 51 size_t getUsed();
NegativeBlack 3:d30db8752485 52 size_t getFree();
NegativeBlack 3:d30db8752485 53 size_t getTotal();
NegativeBlack 3:d30db8752485 54 };
NegativeBlack 3:d30db8752485 55
NegativeBlack 3:d30db8752485 56 } // namespace network
NegativeBlack 3:d30db8752485 57
NegativeBlack 3:d30db8752485 58 #endif // _NETWORK_UDP_SOCKET_HPP_