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
Diff: tcp/socket.hpp
- Revision:
- 4:d854fa394f85
- Parent:
- 3:d30db8752485
diff -r d30db8752485 -r d854fa394f85 tcp/socket.hpp --- a/tcp/socket.hpp Wed Jul 18 11:22:37 2012 +0000 +++ b/tcp/socket.hpp Wed Jul 18 13:20:32 2012 +0000 @@ -26,6 +26,7 @@ #ifndef _NETWORK_TCP_SOCKET_HPP_ #define _NETWORK_TCP_SOCKET_HPP_ +#include "../buffer.hpp" #include "../socket.hpp" #include "../ip/address.hpp" #include "../ip/endpoint.hpp" @@ -39,14 +40,19 @@ public: int open(); - int connect(ip::Address &address, int port); + int connect(const char *hostname, int port); + int connect(const std::string hostname, int port); + int connect(const ip::Address &address, int port); int connect(ip::Endpoint &endpoint); int shutdown(); int listen(int max_pending = 10); int accept(Socket &client); + int write(Buffer &buffer); int write(void *data, size_t size); + + int read(Buffer &buffer); int read(void *data, size_t max_size); };