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/TM4C129XNCZAD: NDK socket checking

Part Number: TM4C129XNCZAD

Tool/software: TI-RTOS

What is the correct way to check for a valid socket? The NDK API refference says "For compatibility, network applications must use the NDK header files, and use INVALID_SOCKET for an error condition (not -1),"

Yet the TI-RTOS example projects all have something like:

server = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (server == -1) {
    System_printf("Error: socket not created.\n");
    goto shutdown;
}

And from socketndk.h

#define INVALID_SOCKET (void *)0xFFFFFFFF   /* Used by socket() and accept() */

  • Hi Peter,

    I'd use the -1 like the examples do (and is spec'd by BSD). Our old non-BSD socket (now NDK_socket) call uses the INVALID_SOCKET constant. The NDK is moving toward more complete BSD compatibility in newer versions. The more recent docs are cleaner in this regards.

    Todd
  • Thank you for the insight. I am interested in understanding the history and future of NDK. I have reached out to a field apps engineer. Is this the best path?
  • An FAE or here are both good resources. We are actively trying to always improve the NDK. The may focus recently has been compatibility between the NDK and our wireless networking stacks. This has been driving both of them to be more BSD compliant. Neither was far from it. Mostly little annoying things.
  • What is the need for a propriety stack? Some TM4C example projects use uip or lwIP. What do existing stacks like lwIP lack?

    Why is NDK configured in a GUI? TI-RTOS works well in a GUI, but the scope of TCP/IP is broader. Fitting every application into a drop down menu seems difficult.

    When will the BSD compliant NDK be available for TM4C devices?

  • Peter Borenstein said:
    What is the need for a propriety stack? Some TM4C example projects use uip or lwIP. What did those stacks lack?

    We have had this stack for 18+ years (Well before lwIP) and continue to see value add in it for customers. As long as there is a large enough demand, we will continue to actively add new features. Having said that, customers are free to use different stacks. I'm not really sure I'd call it propriety since we ship the source code (with a nice BSD license) and support it for free. Granted we don't expose it to the community for patch submissions. Maybe I'm stuck in the past a bit on semantics of the word:) Propriety to me basically means black box or we force you to use it.

    Peter Borenstein said:
    Why is NDK configured in a GUI? TI-RTOS works well in a GUI, but the scope of TCP/IP is broader. Fitting every application into a drop down menu seems difficult.

    You are not required to use the GUI. We've found some people like it for the "simple" things. You can use the runtime APIs to configure your system also.

    Peter Borenstein said:
    When will this BSD compliant NDK be available for TM4C devices?

    We currently don't have a new release for TI-RTOS for TivaC planned. We (RTOS/NDK development team) re-access this probably once a quarter, but it has not made it above the cut-off line yet. 

    We are trying to do a better job on updating this site though with known issues: 

    Todd

  • Interesting. I had not noticed the code lacks the common "this software for use solely and exclusively on TI's microcontroller products" line.

    You are continuously helpful.