test
Revision 17:c5089d058eab, committed 2013-05-14
- Comitter:
- emilmont
- Date:
- Tue May 14 09:48:07 2013 +0000
- Parent:
- 16:2d471deff212
- Child:
- 18:d56496360fc9
- Commit message:
- Not shutting down the socket, before closing it, is not robust in lwIP
Changed in this revision
Socket.cpp | Show annotated file Show diff for this revision Revisions of this file |
Socket.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/Socket.cpp Fri Mar 01 15:30:16 2013 +0000 +++ b/Socket.cpp Tue May 14 09:48:07 2013 +0000 @@ -69,10 +69,12 @@ return select(&timeout._time, false, true); } -int Socket::close() { +int Socket::close(bool shutdown) { if (_sock_fd < 0) return -1; + if (shutdown) + lwip_shutdown(_sock_fd, SHUT_RDWR); lwip_close(_sock_fd); _sock_fd = -1;
--- a/Socket.h Fri Mar 01 15:30:16 2013 +0000 +++ b/Socket.h Tue May 14 09:48:07 2013 +0000 @@ -65,9 +65,10 @@ */ int get_option(int level, int optname, void *optval, socklen_t *optlen); - /** Close the socket file descriptor + /** Close the socket + \param shutdown free the left-over data in message queues */ - int close(); + int close(bool shutdown=true); ~Socket();