Hi,
at the last Network Stack Task Force meeting, we came to the conclusion that a task force for defining API's for network functionality like sockets or coap would be useful.
So I'd like to start this and invite everyone to join!
I'll start the discussion with my opinion on the need for a new socket API.
It was discussed if we couldn't just adopt the BSD/POSIX socket API, as we would need that API anyways.
In my opinion, it has some drawbacks for embedded usage. Best example: (From "man 7 socket"): --- snip --- SYNOPSIS #include <sys/socket.h>
sockfd = socket(int socket_family, int socket_type, int protocol); --- snip ---
This is the function that creates a socket and returns a handle. In malloc-capable systems, this is perfectly fine. In RIOT, the question arises, what does the returned fd mean?
The socket will definately need some state. This needs to be somewhere in memory. Using that API, we'd need to either preallocate a certain amount of socket state structures, or use malloc. Both ways suck.
So a new socket library might more look like:
--- snip --- socket = socket(socket_t *sock, blah) ... --- snip --- That way, the caller has to provide all memory needed for managing the socket.
We do it like that all over RIOT, so I'd like to see this adopted for sockets.
I also believe that it is very easy to implement BSD sockets once these RIOT sockets are in place, adding the memory burden. It is not possible to do it the other way around...
Thoughts?
Kaspar