mirror of https://github.com/ARMmbed/mbed-os.git
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
parent
71efccb1e8
commit
c3eec0322b
|
@ -207,7 +207,7 @@ int ESP8266Interface::socket_recvfrom(void *handle, SocketAddress *addr, void *d
|
||||||
return socket_recv(socket, data, size);
|
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;
|
struct esp8266_socket *socket = (struct esp8266_socket *)handle;
|
||||||
_esp.setTimeout(ESP8266_MISC_TIMEOUT);
|
_esp.setTimeout(ESP8266_MISC_TIMEOUT);
|
||||||
|
|
|
@ -174,9 +174,8 @@ protected:
|
||||||
|
|
||||||
/** Close the socket
|
/** Close the socket
|
||||||
\param handle Socket handle
|
\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
|
/** Register a callback on when a new connection is ready
|
||||||
\param handle Socket handle
|
\param handle Socket handle
|
||||||
|
|
|
@ -480,7 +480,7 @@ int LWIPInterface::socket_recvfrom(void *handle, SocketAddress *addr, void *buf,
|
||||||
return copied;
|
return copied;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LWIPInterface::socket_close(void *handle, bool shutdown)
|
int LWIPInterface::socket_close(void *handle)
|
||||||
{
|
{
|
||||||
struct lwip_socket *s = (struct lwip_socket *)handle;
|
struct lwip_socket *s = (struct lwip_socket *)handle;
|
||||||
|
|
||||||
|
@ -490,10 +490,6 @@ int LWIPInterface::socket_close(void *handle, bool shutdown)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case NSAPI_TCP:
|
case NSAPI_TCP:
|
||||||
if (shutdown) {
|
|
||||||
tcp_abort(s->tcp);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tcp_close(s->tcp)) {
|
if (tcp_close(s->tcp)) {
|
||||||
return NSAPI_ERROR_DEVICE_ERROR;
|
return NSAPI_ERROR_DEVICE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,9 +161,8 @@ protected:
|
||||||
|
|
||||||
/** Close the socket
|
/** Close the socket
|
||||||
\param handle Socket handle
|
\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
|
/** Register a callback on when a new connection is ready
|
||||||
\param handle Socket handle
|
\param handle Socket handle
|
||||||
|
|
|
@ -201,9 +201,8 @@ protected:
|
||||||
|
|
||||||
/** Close the socket
|
/** Close the socket
|
||||||
* @param handle Socket handle
|
* @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
|
/** Register a callback on when a new connection is ready
|
||||||
* @param handle Socket handle
|
* @param handle Socket handle
|
||||||
|
|
|
@ -27,7 +27,7 @@ Socket::Socket()
|
||||||
Socket::~Socket()
|
Socket::~Socket()
|
||||||
{
|
{
|
||||||
if (_socket) {
|
if (_socket) {
|
||||||
close(false);
|
close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,13 +37,13 @@ int Socket::open(NetworkInterface *iface, nsapi_protocol_t proto)
|
||||||
_socket = _iface->socket_create(proto);
|
_socket = _iface->socket_create(proto);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Socket::close(bool shutdown)
|
int Socket::close()
|
||||||
{
|
{
|
||||||
if (!_socket) {
|
if (!_socket) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int err = _iface->socket_close(_socket, shutdown);
|
int err = _iface->socket_close(_socket);
|
||||||
if (!err) {
|
if (!err) {
|
||||||
void *socket = _socket;
|
void *socket = _socket;
|
||||||
_socket = 0;
|
_socket = 0;
|
||||||
|
|
|
@ -60,9 +60,8 @@ public:
|
||||||
int get_option(int optname, void *optval, unsigned *optlen);
|
int get_option(int optname, void *optval, unsigned *optlen);
|
||||||
|
|
||||||
/** Close the socket
|
/** Close the socket
|
||||||
* @param shutdown free the left-over data in message queues
|
|
||||||
*/
|
*/
|
||||||
int close(bool shutdown=true);
|
int close();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Socket();
|
Socket();
|
||||||
|
|
Loading…
Reference in New Issue