Hi,
I am building an MQTT application on my CC3200 following this example (using Paho client): https://github.com/stellascapes/mqtt-examples/blob/master/mqtt
I now have the problem that whenever the broker-connection gets disconnected by the broker, my application gets stuck in the do-while-loop of the read-function:
int cc3200_read(Network* n, unsigned char* buffer, int len, int timeout_ms) {
SlTimeval_t timeVal;
SlFdSet_t fdset;
int rc = 0;
int recvLen = 0;
SL_FD_ZERO(&fdset);
SL_FD_SET(n->my_socket, &fdset);
timeVal.tv_sec = 0;
timeVal.tv_usec = timeout_ms * 1000;
if (sl_Select(n->my_socket + 1, &fdset, NULL, NULL, &timeVal) == 1) {
do {
rc = sl_Recv(n->my_socket, buffer + recvLen, len - recvLen, 0);
recvLen += rc;
} while(recvLen < len);
}
return recvLen;
}
The problem is, that sl_Recv is returning "0", so the (recLen < len) condition will always stay true. Is it correct to say that whenever sl_Rescv returns 0 the connection is broken? Shouldn't it then be a negative return value to indicate an error?
Also my Socket-Error-Handler does not through any error, even though the socket gets terminated.
Thanks for you help,
Henry