Re: RFC: BSD Socket (like) API
Hello Jukka,toggle quoted messageShow quoted text
On Mon, 27 Mar 2017 12:37:40 +0300
Jukka Rissanen <email@example.com> wrote:
That's true, and the reason why I informally proposed the "process-wise"The current approach is that we value lightweight nature of Zephyr,The definition of what is BSD Socket *like* system seems to differ
definition above: "minimal set of changes (additions) to provide
BSD Sockets *like* API to Zephyr."
For me the current net_context API in ZephyrThat's also true, and I right from the start got a habit to call
net_context "a socket". The API calls you mention are all indeed work
(likely almost) the same. The big difference comes with recv() call -
whereas BSD Sockets API has it conventionally pull-style, in Zephyr
it's push-style, where data gets delivered to an app via a callback.
That's one single feature which makes porting 3rd-party applications
complicated and cumbersome.
Right. And that part is covered by BSD Sockets' own API - the data is
passed via app-owned buffers, not system-owned buffers. That means that
by definition, BSD Sockets don't support zero-copy operation. While an
obvious drawback, it has its positive sides to, like it offers
possibility for better system vs app separation for security.
* The net_context is asynchronous and caller needs to have callbacksAs you may already noticed, I prefer to call this distinction
"push-style vs pull-style", because it pinpoints the problem better. The
net_context used "in synchronous way" doesn't provide BSD Sockets
behavior for receives. For that to work, incoming (but unprocessed) data
needs to be queue *per socket*, until an app requests it. And indeed,
that's the one big initial change I would need to make.
Having a BSD socket API on top of net_context will use more memory so+100, BSD Sockets like API is not a replacement for native API, only a
helper to port existing applications (mostly libraries in the
real-world cases, I may imagine, but only practice will tell how
people will use it).
Linaro.org | Open source software for ARM SoCs
Follow Linaro: http://www.facebook.com/pages/Linaro
http://twitter.com/#!/linaroorg - http://www.linaro.org/linaro-blog