fork

Files at this revision

API Documentation at this revision

Comitter:
RobMeades
Date:
Mon Mar 26 15:33:40 2018 +0100
Parent:
14:e7dcf3388403
Child:
16:2b30a056ae54
Commit message:
Add a check in socket_recv() and socket_send() to see whether the socket has been closed by the remote host. If it has, return NSAPI_ERROR_NO_SOCKET immediately. This is necessary as the socket layers above us have no way of knowing if the remote host has closed the socket. Such a check is not required for socket_recvfrom() and socket_sendto() as UDP has no concept of a socket-connection in the first place.

Changed in this revision

UbloxATCellularInterface.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/UbloxATCellularInterface.cpp	Fri Mar 02 13:28:32 2018 +0000
+++ b/UbloxATCellularInterface.cpp	Mon Mar 26 15:33:40 2018 +0100
@@ -561,6 +561,11 @@
 
     MBED_ASSERT (check_socket(socket));
 
+    if (socket->modem_handle == SOCKET_UNUSED) {
+        tr_debug("socket_send: socket closed");
+        return NSAPI_ERROR_NO_SOCKET;
+    }
+
     while ((count > 0) && success) {
         if (count < blk) {
             blk = count;
@@ -669,6 +674,11 @@
 
     MBED_ASSERT (check_socket(socket));
 
+    if (socket->modem_handle == SOCKET_UNUSED) {
+        tr_debug("socket_recv: socket closed");
+        return NSAPI_ERROR_NO_SOCKET;
+    }
+
     timer.start();
 
     while (success && (size > 0)) {