Hello
Please tell me about FreeRTOS_accept()
How do I put in my code to make sure that a timeout has occurred?
よろしくお願いいたします。
Hello
Please tell me about FreeRTOS_accept()
How do I put in my code to make sure that a timeout has occurred?
よろしくお願いいたします。
Hi @taki
FreeRTOS_accept() has an optional timeout option. It could be used by setting receive block time on the listening socket using FreeRTOS_setsockopt with FREERTOS_SO_RCVTIMEO parameter. This will set the maximum time the FreeRTOS_accept function will block while waiting for a connection.
Please find more information here.
Thank you for your reply.
I understand the timeout settings.
Could you please tell me how to determine from the code whether it timed out or connected?
Thank you
See the API docs already posted by @moninom1
Thank you for your reply.
Is the following correct?
If timeout occurs, do not come to the NG side
xConnectedSocket = FreeRTOS_accept( xListeningSocket, &xClient, &xSize );
//OK
if(xConnectedSocket != 0){
}
//NG
else{
}
I don’t know what NG is, but your check of the return value is ok.
In fact it’s the handle of/pointer to the accepted socket or NULL pointer.
Although I’d use NULL in C-code or nullptr in C++ code rather than ‘0’ ![]()
Thank you for your reply.
If return value is ok,
maybe there’s a mistake in my code
I will review the code
Thank you
hi @taki,
These are the return values of FreeRTOS_accept():
Returns:
If a connection from a remote socket is accepted and a new local socket is created to handle the accepted connection then a handle to the new socket is returned.
If xServerSocket is not a valid TCP socket then then FREERTOS_INVALID_SOCKET is returned.
If xServerSocket is not in the Listening state (see FreeRTOS_listen()) then FREERTOS_INVALID_SOCKET is returned.
If a timeout occurs before a connection from a remote socket is accepted then NULL is returned.
You can refer to the entire documentation at: FreeRTOS_accept