9 years, 4 months ago.

Program freezing when internet turns off?

I have quite a lot of code but the basic template is this:

//Includes and Defines

//Functions

int main()
{
wifi.connect();
ws.connect();

while(true)
{
//get temp
//print temp

ws.send(temp)
ws.read(recv)
}
}

I'm using cc3000 and websocketclient and have got both working fine but when my internet crashes the program freezes in ws.read instead of timing out and carrying on. Further looking pinpoints the freeze to the TCPSocketConnection.cpp recieve function in the socket library. Any help would be much appreciated.

Where is the network port set to non-blocking and what timeout is it set to?

posted by Andy A 17 Dec 2014

It's not in my program but in the WebsocketClient.cpp read function:

socket.set_blocking(false, 1);
        if (socket.receive(&opcode, 1) != 1) {
            socket.set_blocking(false, 500);
            return false;
        }
posted by Marcus Parker 17 Dec 2014
Be the first to answer this question.