ap

Dependencies:   DnsQuery

Dependents:   WizFi310_TCP_Echo_Server_Example

Fork of NetworkSocketAPI by NetworkSocketAPI

Revision:
93:65a9f84862f0
Parent:
92:dd5f19874adf
Child:
98:0f614f1d0398
--- a/Socket.cpp	Tue Apr 19 18:23:29 2016 -0500
+++ b/Socket.cpp	Tue Apr 19 18:23:42 2016 -0500
@@ -34,8 +34,17 @@
 int Socket::open(NetworkInterface *iface, nsapi_protocol_t proto)
 {
     _iface = iface;
-    _socket = _iface->socket_create(proto);
+
+    void *socket;
+    int err = _iface->socket_open(&socket, proto);
+    if (err) {
+        return err;
+    }
+
+    _socket = socket;
     _iface->socket_attach(_socket, &Socket::thunk, this);
+
+    return 0;
 }
 
 int Socket::close()
@@ -44,14 +53,9 @@
         return 0;
     }
 
-    int err = _iface->socket_close(_socket);
-    if (!err) {
-        void *socket = _socket;
-        _socket = 0;
-        _iface->socket_destroy(socket);
-    }
-
-    return err;
+    void *socket = _socket;
+    _socket = 0;
+    return _iface->socket_close(socket);
 }
 
 void Socket::set_blocking(bool blocking)