So i am unable to find in the documentation of the NDK on how to set a TCP connection timeout value. is there a socket option i am missing?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
So i am unable to find in the documentation of the NDK on how to set a TCP connection timeout value. is there a socket option i am missing?
Hi cobsonchael,
The socket option 'SO_RCVTIMEO' for the function setsockopt() should help set a timeout on input operations. See if that is what you are looking for.
The NDK API user guide has more details on getsockopt().
Best regards,
Vincent
just to be exact: the connection timeout is for the connection attempt ONLY and not for also the transmit and receive timeouts as well?
Hi,
the one in the Image before is for the connect. You can see the details if you go to the Advanced options in the IP Settings:
you can see that the one I set to 10s is only for the connection and "socketIoTimeout" to read and write on the socket. If you want to set timeouts for sending or receiving, you can do it using the properties of the socket itself:
struct timeval to;
to.tv_sec = 30;
to.tv_usec = 0;
setsockopt( yourSocket, SOL_SOCKET, SO_SNDTIMEO, &to, sizeof( to ))
setsockopt( yourSocket, SOL_SOCKET, SO_RCVTIMEO, &to, sizeof( to ))
for example, to set 30s for receive and send timeouts.
Greetings,
Sara
Hi cobsonchael,
If you are looking for a timeout for the connect() function call, then you should follow Sara's suggestion to set Ip.socketConnectTimeout. This would not affect transmit and receive timeouts.
Fyi, here is another thread that discusses the behavior for Ip.socketConnectTimeout:
http://e2e.ti.com/support/embedded/tirtos/f/355/p/123605/443315#443315
Best regards,
Vincent