Re: TCP assert error logs

Paul Sokolovsky

Hello Vakul,

On Thu, 14 Sep 2017 05:14:55 +0000
Vakul Garg <> wrote:


Yes, POSIX bits is Zephyr are very initial and very bare so far - a
bit of threads and a bit of sockets support. There're neither
full-featured poll() implementation, nor fd's (file descriptors),
nor other POSIX IPC.
I used TCP/UDP POSIX sockets between two local apps just because I
thought I can't multiplex a local IPC method such as mailbox/pipe
with network sockets connected to a remote endpoint.

If I change my code to use net_context apis for remote networking and
use mailbox/pipe between local apps, will I be able to multiplex
net_contexts with mailbox/pipes using k_poll mechanism?
Yes, there's k_poll() which can work with native Zephyr synchronization
primitives. But synchronization primitives is also what it's limited
to. A net context is not such. You interact with it not by using k_poll,
but by installing callbacks which will be called when something happens.

Then you can do something in a callback (put something in a queue,
release a semaphore, raise an event), and use that with k_poll. But
that's exactly how sockets are implemented!

So, there're few choices:

1. Implement more POSIX synchronization primitives. That would take
some time and effort of course.

2. If needed to be done quickly for experimentation, can use sockets'
net_context::recv_q in k_poll, with a usual warning that it's not
intended to be used like that, and is an implementation detail which can
be changed at any time.

3. The worst way (IMHO) is to duplicate what BSD Sockets already do in
some adhoc code. This way, Zephyr doesn't grow POSIX functionality,
doesn't have its sockets subsystem used, but the adhoc code is all
yours to maintain ;-).


Best Regards,
Paul | Open source software for ARM SoCs
Follow Linaro:!/linaroorg -

Join to automatically receive all group messages.