NetworkSocketAPI
Dependents: HelloWizFi250Interface
Fork of NetworkSocketAPI by
Diff: NetworkInterface.h
- Revision:
- 11:47c32687a44c
- Parent:
- 10:50b0a3f840df
- Child:
- 12:ab3679eb4d9d
--- a/NetworkInterface.h Wed Jul 15 15:41:11 2015 +0000 +++ b/NetworkInterface.h Wed Jul 15 23:21:17 2015 +0000 @@ -19,6 +19,9 @@ #include "stdint.h" +#include "SocketInterface.h" +#include <map> + /** NetworkInterface class. This is a common interface that is shared between all hardware that connect to a network over IP. @@ -77,6 +80,25 @@ @returns true if connected, a negative number on failure */ virtual int32_t isConnected(void) const = 0; + + /** Allocate space for a socket. + @returns a pointer to the allocated socket. + */ + virtual SocketInterface* allocateSocket(socket_protocol_t socketProtocol) const = 0; + + /** Deallocate space for a socket. + @returns a pointer to the deallocated socket. + */ + virtual int deallocateSocket(SocketInterface* socket) const = 0; + +protected: + /** Map used to keep track of all SocketInterface instances */ + std::map<int, SocketInterface*> sockets; + + /** Counter used to create unique handles for new sockets. + Should be incremented whenever a new socket is created. + */ + uint32_t uuidCounter; }; #endif