This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Which socket TCP or BSD

Hello,

I am a bit confused as to which API I should use for communication with PC running Win7.
Seems like the TCP api is more event driven whereas the BSD is the classic implementation. Does the TCP is implemented on top of the BSD sockets or they are not related at all. Do they both require RTX running
The Microcontroller will run as a TCP server.

Many thanks
Nick

Parents
  • All networking stacks are supporting TCP/IP and UDP/IP since the huge majority of all networking is using these two protocols for the transmitted data.

    Berkley sockets is basically a design concept (and not the only one) with function calls suitable for writing networking software. So it can be seen as a "portability" solution for how a program will interface with the networking stack. And you can most definitely use both TCP or UDP depending on your needs.

    If you are going to use TCP or UDP depends on what problem you want to solve. UDP doesn't have connections and data can be lost. But is much faster, since it never hangs waiting for any acknowledge.

Reply
  • All networking stacks are supporting TCP/IP and UDP/IP since the huge majority of all networking is using these two protocols for the transmitted data.

    Berkley sockets is basically a design concept (and not the only one) with function calls suitable for writing networking software. So it can be seen as a "portability" solution for how a program will interface with the networking stack. And you can most definitely use both TCP or UDP depending on your needs.

    If you are going to use TCP or UDP depends on what problem you want to solve. UDP doesn't have connections and data can be lost. But is much faster, since it never hangs waiting for any acknowledge.

Children
  • I wonder if you're asking about the specific TCPnet implementation supplied by Keil.

    Historically, the TCPnet libraries only supported what I think you are referring to as the TCP API. It can be used both with or without the RTX.

    It provides quite a lot of control, but my personal opinion is that it's not very 'programmer friendly'. For example, the TCP related functions are not re-entrant and the documentation states "All TCPnet-related functionality should be collected in a single networking task". Of course, limitations like these can be overcome, but it certainly took me a considerable time to feel I was controlling it reliably.

    The BSD socket interface was added to TCPnet relatively recently. It attempts to implement a standard Berkeley Socket communication interface. But the documentation states that "These APIs are not a complete implementation of the BSD API". It sits on top of (and makes use of) the original networking facilities.

    I have not used this BSD support, but as far as I am aware they are re-entrant, require the RTX and, being more standard, are more likely to be easier for someone to learn how to use them.

    For any new project, it would probably be sensible to seriously consider using the BSD API.

  • Thanks IB Shy, this was the answer I was looking for.

  • The interesting thing about the Berkeley socket interface is that almost all networking sample code on the net is for (or almost for) this API. And the majority of all network programming books describes this API and shows sample code for (or almost for) this API.

    This is because the Berkeley sockets is the foundation for what later evolved into POSIX Sockets.

  • Note that the choice of API has nothing to do with the type of the remote host.