TCPClient as simple logger [SOLVED]

I’ve came up with following code that looks pretty reasonable for me and manages to send requests at decent rate.

 uint32_t before = micros();

if(client.connect(server, 9606)) {
    client.println("GET /v.php?"+requestSrting+" HTTP/1.0");
    client.println("Content-Length: 0");
    client.println();
    uint32_t startWait = micros();
    while(!client.available() && micros() < startWait + 5000) {delayMicroseconds(5);} /** We wait to server starts actually responding. Timeout is 5 miliseconds */
    client.flush();
    client.stop();  
}
uint32_t after = micros();

averageCount++;
averageTime = (after - before)/averageCount; //Count average request time in micros

Average time is reported as ~166. I think this is a good result
@Dave is this looking fine?

1 Like