Wrapper of NetworkSocketAPI for BSD sockets on POSIX systems

Dependents:   BSDInterfaceTests HelloBSDInterface

Revision:
5:1af10f9d9404
Parent:
4:28479a7d15ad
Child:
6:363dd62309cf
--- a/BSDInterface.cpp	Thu Feb 25 19:04:44 2016 -0600
+++ b/BSDInterface.cpp	Thu Feb 25 19:10:07 2016 -0600
@@ -99,7 +99,6 @@
     return mac_address;
 }
 
-
 int32_t BSDInterface::getHostByName(const char *name, char *ip)
 {
     struct hostent *host = gethostbyname(name);
@@ -111,26 +110,6 @@
     return 0;
 }
 
-
-/** BSDSocket class
- *  Implementation of the SocketInterface for BSD
- */
-class BSDSocket : public SocketInterface
-{
-public:
-    BSDSocket(int fd) : fd(fd) {}
-
-    // Implementation of SocketInterface
-    virtual int32_t open(const char *ip, uint16_t port);
-    virtual int32_t close();
-
-    virtual int32_t send(const void *data, uint32_t size);
-    virtual int32_t recv(void *data, uint32_t size);
-
-    int fd;
-};
-
-
 SocketInterface *BSDInterface::createSocket(ns_protocol_t proto)
 {
     int type = (proto == NS_UDP) ? SOCK_DGRAM : SOCK_STREAM;
@@ -149,8 +128,8 @@
 }
 
 
-// UDP SocketInterface implementation
-int32_t BSDSocket::open(const char *ip, uint16_t port)
+// BSDSocket implementation
+int32_t BSDInterface::BSDSocket::open(const char *ip, uint16_t port)
 {
     struct sockaddr_in host;    
     memset(&host, 0, sizeof host);
@@ -165,12 +144,12 @@
     return 0;
 }
 
-int32_t BSDSocket::close()
+int32_t BSDInterface::BSDSocket::close()
 {
     return 0;
 }
 
-int32_t BSDSocket::send(const void *data, uint32_t size)
+int32_t BSDInterface::BSDSocket::send(const void *data, uint32_t size)
 {
     if (::send(fd, data, size, 0) < 0) {
         return NS_ERROR_DEVICE_ERROR;
@@ -179,7 +158,7 @@
     return 0;
 }
 
-int32_t BSDSocket::recv(void *data, uint32_t size)
+int32_t BSDInterface::BSDSocket::recv(void *data, uint32_t size)
 {
     int ret = ::recv(fd, data, size, MSG_DONTWAIT);