-
Notifications
You must be signed in to change notification settings - Fork 25
Description
For TCP, there are two kinds of sockets, those bound (on which accept
makes sense), and those connected or accepted (on which read/write makes sense). These are the same type in POSIX systems, but completely different eg. in RIOT.
This is similar to #33 in methods, but different in goals (#33 is about when what can be called on the same sockets; feel free to close as duplicate if you disagree).
I suggest that the Socket associated type of TcpClientStack be split into a ConnectionSocket and a ListeningSocket, which can still be the same types on POSIX-style systems but distinct on others. (If #33 is followed, a ConnectionSocket would then be further split into its unconnected and its connected version, and the listening into its unbound, bound and listening versions).
Alternatively, sockets on such platforms need to be union-typed (enum Socket { Unspecified, ConnectionSocket(sock_t), ListeningSocket(sock_listener_t) }
), and always check on runtime whether the right kind is used, which feels not very idiomatic.