Why is RTCS_accept(0) returning socket of HTTP Server

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Why is RTCS_accept(0) returning socket of HTTP Server

Jump to solution
647 Views
razed11
Contributor V

Hi,

I'm using MQX 4.1.1, K64, IAR.

I have a task that calls HTTPSRV_init() and later creates a TCP listening socket per the example code on port 17 for quote-of-the-day. If I have the demo webpages loaded in a browser that is periodically calling the CGI for time I noticed that RTCS_selectall(0) returns the socket ID for my HTTP server.

The documentation suggests that the RTCS_selectall(0) will return a listening stream for any sockets that the task owns.

But the HTTP server is a different task so why is this happening? Also is there a way within the RTCS TAD to see the ID of the task that owns the socket? I didn't see this but it seems like it would useful in this case.

Edit: I have since made my socket code a separate task that is launched by the same task that called HTTPSRV_init() and RTCS_select(0) is still returning during HTTP requests.

Thanks,

Kenny

Labels (1)
0 Kudos
1 Solution
433 Views
Martin_
NXP Employee
NXP Employee

We have not used RTCS_selectall() in any application/demo code, so it can be seen as not tested. It is possible MQX 4.1 has a bug in this function. RTCS_selectset() shall be used instead. In MQX for Kinetis SDK we have already introduced the new BSD-like select() function, with standard interface using FD_SET/FD_CLR/FD_ZERO/FD_ISSET interface. This is the recommended API for new applications. RTCS_selectall/RTCS_selectset have been re-implemented with the select() function, so RTCS_selectall() can be used again, starting with MQX for Kinetis SDK.

-Martin

View solution in original post

0 Kudos
3 Replies
433 Views
razed11
Contributor V

I've solved my problem by using RTCS_selectset with the single listening socket. I'd still like to understand what is happening with selectall() and the relationship between sockets and the tasks that own them.

Would detach/attach been a better option?

Thanks,

Kenny

0 Kudos
434 Views
Martin_
NXP Employee
NXP Employee

We have not used RTCS_selectall() in any application/demo code, so it can be seen as not tested. It is possible MQX 4.1 has a bug in this function. RTCS_selectset() shall be used instead. In MQX for Kinetis SDK we have already introduced the new BSD-like select() function, with standard interface using FD_SET/FD_CLR/FD_ZERO/FD_ISSET interface. This is the recommended API for new applications. RTCS_selectall/RTCS_selectset have been re-implemented with the select() function, so RTCS_selectall() can be used again, starting with MQX for Kinetis SDK.

-Martin

0 Kudos
433 Views
razed11
Contributor V

Thank you Martin. That's fine. I was concerned that I didn't understand things fully.

FYI: The RTCS guide Rev 16 uses RTCS_selectall(0) in the example at the end of the socket section. I just copied it from the PDF and modified to my needs.

As a suggestion it might be nice to see a socket's owner task in the RTCS TAD.

0 Kudos