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.

RTOS/66AK2H12: tcp/ip socket support across tasks

Part Number: 66AK2H12

Tool/software: TI-RTOS

I am working on a design that requires TPC/IP server support. In the past I've opened a listener socket and once a client connects, spawn off a receiver thread and a transmit thread sharing the connected socket. I'm trying to do this new with a sys/bios Task pair and it is not working. I use DaemonNew to setup the server. On a client connection the call back I pass to DaemonNew is call and my intent was to use that has the receive thread in an infinite loop blocking on recvnc() but before doing that, I Task-create() my transmit thread.

When I queue something to the transmit tread after receiving a request on the recv thread, my client gets only a single byte, my application shows a socket error and then shortly there after crashes. I've check under CCS debug my the socket number on the transmit side is correct, the byte count to send is correct and the send buffer pointer is correct. All data is protected with critical sections, the socket itself is not.

Is this approach flawed under sys/bios?

(SYS/BIOS 6.46, XDCtools 3.32, NDK 2.25)

  • Hi,

    I've notified the RTOS team. Their feedback will be posted here.

    Best Regards,
    Yordan
  • Thanks. A couple more details -

    I get recvnc() data on the connection callback thread.
    I try to send via my new task thread on the same socket but it fails
    The receiver call on the call back thread than returns with an error at which point I signal the transmit thread to terminate.

    The client task never receives any data (I erroneously indicated before that one byte was received).

    I was closing the socket on the call back receive thread but now I'm closing on the transmit thread and for some reason that doesn't cause the application to crash. Not sure why.
  • Mike,

    We are looking into this and shall get back to you.

    Lali
  • No response ? We finally figured it out for ourselves and the answer should have been very easy for someone with SYS/BIOS NDK experience and to me had I completely read the NDK API documentation.

    Sharing a SOCKET across tasks is like sharing a file descriptor. To use file descriptors a new task needs to first allocate a file descriptor table using fdOpenSession(). Then to share the SOCKET descriptor (file descriptor) fdShare() is used.

    My exact situation is described in the NDK API: "For example, fdShare() is useful in a case where Task A opens a session and calls recv() in a loop on a socket. Task B has a loop that calls send() on the same socket. The call to send() from Task B will fail and then fdError() will return -1 if you do not call fdOpenSession() and then fdShare() from the second Task after the first Task has opened the socket."