NetworkSocketAPI

Dependencies:   DnsQuery

Dependents:   HelloWizFi250Interface

Fork of NetworkSocketAPI by NetworkSocketAPI

Revision:
90:0a988e4abb72
Parent:
89:b1d417383c0d
Child:
92:dd5f19874adf
--- a/TCPServer.cpp	Tue Apr 19 18:20:38 2016 -0500
+++ b/TCPServer.cpp	Tue Apr 19 18:22:15 2016 -0500
@@ -17,9 +17,18 @@
 #include "TCPServer.h"
 #include "Timer.h"
 
+TCPServer::TCPServer()
+{
+}
+
 TCPServer::TCPServer(NetworkInterface *iface)
-    : Socket(iface, NSAPI_TCP)
 {
+    open(iface);
+}
+
+int TCPServer::open(NetworkInterface *iface)
+{
+    return Socket::open(iface, NSAPI_TCP);
 }
 
 int TCPServer::bind(uint16_t port)
@@ -45,15 +54,16 @@
     mbed::Timer timer;
     timer.start();
 
-    void *socket = connection->_socket;
-    connection->_socket = 0;
-    _iface->socket_destroy(socket);
+    if (connection->_socket) {
+        connection->close();
+    }
 
     while (true) {
         if (!_socket) {
             return NSAPI_ERROR_NO_SOCKET;   
         }
 
+        void *socket;
         int err = _iface->socket_accept(_socket, &socket);
 
         if (err > 0) {