From a7e6c105b3ea2866b134194856a823d0cd207b1e 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 --- NetworkInterface.h | 3 +-- Socket.cpp | 6 +++--- Socket.h | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/NetworkInterface.h b/NetworkInterface.h index 28ad41e28e..26cd98cbac 100644 --- a/NetworkInterface.h +++ b/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/Socket.cpp b/Socket.cpp index e52ba47793..53d66a635b 100644 --- a/Socket.cpp +++ b/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/Socket.h b/Socket.h index ebae4440e0..376e73a41c 100644 --- a/Socket.h +++ b/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();