I am using TCPClient.write() to send data to the server. I am posting a stuff to the server in JSON format. The write() function returns 176 bytes written and the size of the data I sent was also 176 bytes. But I do not see anything on the server. If write() returns a valid number of bytes doesn’t it mean there was a successful write on the server? Here is the code snippet.
char dataToSend[200];
sprintf(dataToSend, "POST /location/%s HTTP/1.1\r\nHost:%s\r\nContent-Type:application/json\r\nContent-Length:%d\r\n\n%s\r\n0x1A", "865067021570786", "nwan.noip.me", 61, "\"lat\":53.645438, \"log\":10.164412, \"timestamp\":1471284581534");
if (!client.connected()) {
client.connect(myServer, 8020);
}
if (client.connected()) {
int size = strlen(dataToSend);
int written = client.write((unsigned char *)dataToSend, size);
client.print(',');
Serial.printlnf("DataSize: %d, Bytes written: %d", size, bytes);
}
I get this output:
DataSize: 176, Bytes written: 176