mbed socket API

Dependents:   EthernetInterface EthernetInterface_RSF EthernetInterface EthernetInterface ... more

Deprecated

This is an mbed 2 sockets library. For mbed 5, network sockets have been revised to better support additional network stacks and thread safety here.

Files at this revision

API Documentation at this revision

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();