Support for poll (or select)

Hi there!

Do you support poll (or select) on sockets or do you plan to add it in the near future?

  Raphael

Hi,

Hi Raphael,

I tried to implement select 6 months ago and stopped working on it, because of several reasons:

1. the interface to the network (transceiver thread) is riot msg based (IPC), which is non blocking, but the IP stacks API (to applications) is blocking only, which one needs to change. 2. I think the IP stack is using a msg_receive to get new packets from the transceiver, this would need to get changed to msg_receive_timeout. 3. all RIOT IPC code is blocking, so a lot places do need changes. 4. the async posix IO is ugly, perhaps have a look at: https://github.com/mehlis/ipv6-client/blob/master/nonblocking.0.c 6. for an epoll example have a look at https://github.com/mehlis/ipv6-client/blob/master/nonblocking.1.c 7. in RIOT we don't have a generalized file descriptor model

In case you want to invest your time in async posix IO feel free to do it. In case you need almost full support for select: Start on code dealing with state changes in file descriptors (this will trigger select to return).

Some major bugs in vtimer and native forced me stop my work, but they are now fixed!

For the CCN-lite network stack I'm using two threads: the first one is dealing with msg events, msg_receive (blocking) which can receive msgs from different threads and the other one handles the timeout part (sleep, blocking). Mutexes are needed in this case.

Best Christian

Hi Christian,

I tried to implement select 6 months ago and stopped working on it, because of several reasons:

thank you for sharing your experience on this topic. Much appreciated.

1. the interface to the network (transceiver thread) is riot msg based (IPC), which is non blocking, but the IP stacks API (to applications) is blocking only, which one needs to change.

Maybe it's easier to do the socket multiplexing on top of RIOT IPC then. In libcppa, we have a poll/epoll backend to do the multiplexing. We thought it might be easier to add poll() to RIOT than porting our networking backend. After reading your mail, though, I think porting libcppa to the IPC-based multiplexing is probably more straightforward.

2. I think the IP stack is using a msg_receive to get new packets from the transceiver, this would need to get changed to msg_receive_timeout. 3. all RIOT IPC code is blocking, so a lot places do need changes. 4. the async posix IO is ugly,

I would go as far as to say the whole POSIX API is ugly and heavily outdated. But it's the most portable way to write applications...

perhaps have a look at: https://github.com/mehlis/ipv6-client/blob/master/nonblocking.0.c 6. for an epoll example have a look at https://github.com/mehlis/ipv6-client/blob/master/nonblocking.1.c 7. in RIOT we don't have a generalized file descriptor model

In case you want to invest your time in async posix IO feel free to do it. In case you need almost full support for select: Start on code dealing with state changes in file descriptors (this will trigger select to return).

Some major bugs in vtimer and native forced me stop my work, but they are now fixed!

For the CCN-lite network stack I'm using two threads: the first one is dealing with msg events, msg_receive (blocking) which can receive msgs from different threads and the other one handles the timeout part (sleep, blocking). Mutexes are needed

We'll have a look at this stack. Maybe we can extract the building blocks we need to build our network backend. :slight_smile:

Best wishes, Dominik

The code I'm talking about is not yet in master (to keep the release as stable as possible).

I'm currently working on different topics in the stack...so you can have a look at https://github.com/RIOT-OS/RIOT/pull/1026, which is WIP and not in mergeable quality...(need to split this PR in handy parts).

start here: https://github.com/mehlis/RIOT/blob/ccnl-helper-thread/sys/net/ccn_lite/ccn-lite-relay.c#L394 <- this is the start function of the ccn lite stack in RIOT.

here you have the posix code which I ported to RIOT: https://github.com/mehlis/ccn-lite/blob/master/ccn-lite-relay.c#L418

If you have questions about the concepts I used to port code from select to RIOT, just drop a mail!

Best Christian

Hi,