Hi,

I was going to start implementing a socket-style API for IP
transport layer connections. To start with, I would use this
with Wi-Fi controllers with integrated IP stacks.

int socket(struct socket *, uint8_t domain, uint8_t type, uint8_t protocol);
The caller of the socket() should allocate memory for the
socket data structure itself. This allows bundling other
data related to connection together with the socket.


Event notifications from socket would be delivered via
callbacks. Naturally, callback would not be called within task
context, so it would most likely be turned into an os_event and
queued for processing in task context via os_eventq.

struct socket_cb {
  void *(readable)(struct socket *);
  void *(writable)(struct socket *);
};
void socket_register_cb(struct socket *, struct socket_cb *);
I could be convinced that the notifications should directly
be delivered to os_eventq. 


For TX and RX, sendto() and recvfrom(). And setsockopt()
and getsockopt().

For closing the socket, close(). shutdown() would allow more
flexibility, but I don’t think we need that.


Reply via email to