From c3eec0322ba124debb84e54f20c9e4ab617c138c Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Sun, 13 Mar 2016 07:13:14 -0500 Subject: [PATCH] Remove shutdown parameter from close call Pros - Simplifies interface - Easier base implementation Cons - May need shutdown functionality, in this case shutdown can be added as another function in the future --- net/ESP8266Interface/ESP8266Interface.cpp | 2 +- net/ESP8266Interface/ESP8266Interface.h | 3 +-- net/LWIPInterface/LWIPInterface.cpp | 6 +----- net/LWIPInterface/LWIPInterface.h | 3 +-- net/NetworkSocketAPI/NetworkInterface.h | 3 +-- net/NetworkSocketAPI/Socket.cpp | 6 +++--- net/NetworkSocketAPI/Socket.h | 3 +-- 7 files changed, 9 insertions(+), 17 deletions(-) diff --git a/net/ESP8266Interface/ESP8266Interface.cpp b/net/ESP8266Interface/ESP8266Interface.cpp index f675d7618e..b91f29c35c 100644 --- a/net/ESP8266Interface/ESP8266Interface.cpp +++ b/net/ESP8266Interface/ESP8266Interface.cpp @@ -207,7 +207,7 @@ int ESP8266Interface::socket_recvfrom(void *handle, SocketAddress *addr, void *d return socket_recv(socket, data, size); } -int ESP8266Interface::socket_close(void *handle, bool shutdown) +int ESP8266Interface::socket_close(void *handle) { struct esp8266_socket *socket = (struct esp8266_socket *)handle; _esp.setTimeout(ESP8266_MISC_TIMEOUT); diff --git a/net/ESP8266Interface/ESP8266Interface.h b/net/ESP8266Interface/ESP8266Interface.h index 88ce4dcf17..ee5c3a8c9e 100644 --- a/net/ESP8266Interface/ESP8266Interface.h +++ b/net/ESP8266Interface/ESP8266Interface.h @@ -174,9 +174,8 @@ protected: /** Close the socket \param handle Socket handle - \param shutdown free the left-over data in message queues */ - virtual int socket_close(void *handle, bool shutdown); + virtual int socket_close(void *handle); /** Register a callback on when a new connection is ready \param handle Socket handle diff --git a/net/LWIPInterface/LWIPInterface.cpp b/net/LWIPInterface/LWIPInterface.cpp index a39ff0666f..c954059d24 100644 --- a/net/LWIPInterface/LWIPInterface.cpp +++ b/net/LWIPInterface/LWIPInterface.cpp @@ -480,7 +480,7 @@ int LWIPInterface::socket_recvfrom(void *handle, SocketAddress *addr, void *buf, return copied; } -int LWIPInterface::socket_close(void *handle, bool shutdown) +int LWIPInterface::socket_close(void *handle) { struct lwip_socket *s = (struct lwip_socket *)handle; @@ -490,10 +490,6 @@ int LWIPInterface::socket_close(void *handle, bool shutdown) return 0; case NSAPI_TCP: - if (shutdown) { - tcp_abort(s->tcp); - } - if (tcp_close(s->tcp)) { return NSAPI_ERROR_DEVICE_ERROR; } diff --git a/net/LWIPInterface/LWIPInterface.h b/net/LWIPInterface/LWIPInterface.h index 055b7edda2..cf0fb45daf 100644 --- a/net/LWIPInterface/LWIPInterface.h +++ b/net/LWIPInterface/LWIPInterface.h @@ -161,9 +161,8 @@ protected: /** Close the socket \param handle Socket handle - \param shutdown free the left-over data in message queues */ - virtual int socket_close(void *handle, bool shutdown); + virtual int socket_close(void *handle); /** Register a callback on when a new connection is ready \param handle Socket handle diff --git a/net/NetworkSocketAPI/NetworkInterface.h b/net/NetworkSocketAPI/NetworkInterface.h index 28ad41e28e..26cd98cbac 100644 --- a/net/NetworkSocketAPI/NetworkInterface.h +++ b/net/NetworkSocketAPI/NetworkInterface.h @@ -201,9 +201,8 @@ protected: /** Close the socket * @param handle Socket handle - * @param shutdown free the left-over data in message queues */ - virtual int socket_close(void *handle, bool shutdown) = 0; + virtual int socket_close(void *handle) = 0; /** Register a callback on when a new connection is ready * @param handle Socket handle diff --git a/net/NetworkSocketAPI/Socket.cpp b/net/NetworkSocketAPI/Socket.cpp index e52ba47793..53d66a635b 100644 --- a/net/NetworkSocketAPI/Socket.cpp +++ b/net/NetworkSocketAPI/Socket.cpp @@ -27,7 +27,7 @@ Socket::Socket() Socket::~Socket() { if (_socket) { - close(false); + close(); } } @@ -37,13 +37,13 @@ int Socket::open(NetworkInterface *iface, nsapi_protocol_t proto) _socket = _iface->socket_create(proto); } -int Socket::close(bool shutdown) +int Socket::close() { if (!_socket) { return 0; } - int err = _iface->socket_close(_socket, shutdown); + int err = _iface->socket_close(_socket); if (!err) { void *socket = _socket; _socket = 0; diff --git a/net/NetworkSocketAPI/Socket.h b/net/NetworkSocketAPI/Socket.h index ebae4440e0..376e73a41c 100644 --- a/net/NetworkSocketAPI/Socket.h +++ b/net/NetworkSocketAPI/Socket.h @@ -60,9 +60,8 @@ public: int get_option(int optname, void *optval, unsigned *optlen); /** Close the socket - * @param shutdown free the left-over data in message queues */ - int close(bool shutdown=true); + int close(); protected: Socket();