Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 9 months ago.
Continuous updates
Hi, I am sending out regular position updates (once a second) to a server using the TCP example in your demo, do I have to close the socket and re-open it every time? It didn't work until I did this, but now it sometimes the socket won't open and I miss a number of samples.
I run this routine every time I get a valid GPS update:
socket = mdm.socketSocket(MDMParser::IPPROTO_TCP);
if (socket >= 0)
{
mdm.socketSetBlocking(socket, 10000);
if (mdm.socketConnect(socket, host, port))
{
ret = mdm.socketSend(socket, link, n);
printf(link);
mdm.socketClose(socket);
}
mdm.socketFree(socket);
}
but 'socket' returns -1 for a number of samples, so they don't get transmitted, then it starts working fine again.
Question relating to:
1 Answer
8 years, 5 months ago.
You should be able to use socketSend multiple times without closing/reopening the socket. You may want to add error handling in case you are getting out of network coverage.