Why tf is std.socket.Socket an class? #2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why tf is
std.socket.Socketan class to begin with?!?!?! It dosnt usessynchronizedthat would require themonitorof an class, nor does it holds any significant amount of data: 1socket_t(32bit fd), anushortfor the family (16bit) and on windows an boolean to track if it is blocking (since async sockets will always be async, this doesnt affect us): this makes 48bit to pass around, while an pointer on modern system will always be 64bit wide (which would even account for the 1 bool for blocking/no-blocking state!!)So really std is just BADLY engineered or am I going crazy?
Decision: we re-type AsyncSocket to an struct.
Only question: do we want to keep the addressfamily in the type? Currently, the socket is an "catch-all" for all families (UNIX, IPv4, IPX, AppleTalk, IPv6), and only stores it because the
remoteAddressandlocalAddressfunction need it to create the proper address type from it.