Safer to query the closed sock and get an error

This commit is contained in:
Sara Damiano
2019-05-21 18:35:37 -04:00
parent 39beba60b1
commit 96bbf381ad
2 changed files with 4 additions and 8 deletions

View File

@@ -590,8 +590,7 @@ protected:
}
size_t modemGetAvailable(uint8_t mux) {
// Querying a closed socket gives an error "operation not allowed"
if (!sockets[mux]->sock_connected) return 0;
// NOTE: Querying a closed socket gives an error "operation not allowed"
sendAT(GF("+USORD="), mux, ",0");
size_t result = 0;
uint8_t res = waitResponse(GF(GSM_NL "+USORD:"));
@@ -610,8 +609,7 @@ protected:
}
bool modemGetConnected(uint8_t mux) {
// Querying a closed socket gives an error "operation not allowed"
if (!sockets[mux]->sock_connected) return false;
// NOTE: Querying a closed socket gives an error "operation not allowed"
sendAT(GF("+USOCTL="), mux, ",10");
uint8_t res = waitResponse(GF(GSM_NL "+USOCTL:"));
if (res != 1)

View File

@@ -596,8 +596,7 @@ protected:
}
size_t modemGetAvailable(uint8_t mux) {
// Querying a closed socket gives an error "operation not allowed"
if (!sockets[mux]->sock_connected) return 0;
// NOTE: Querying a closed socket gives an error "operation not allowed"
sendAT(GF("+USORD="), mux, ",0");
size_t result = 0;
uint8_t res = waitResponse(GF(GSM_NL "+USORD:"));
@@ -616,8 +615,7 @@ protected:
}
bool modemGetConnected(uint8_t mux) {
// Querying a closed socket gives an error "operation not allowed"
if (!sockets[mux]->sock_connected) return false;
// NOTE: Querying a closed socket gives an error "operation not allowed"
sendAT(GF("+USOCTL="), mux, ",10");
uint8_t res = waitResponse(GF(GSM_NL "+USOCTL:"));
if (res != 1)