Why tf is std.socket.Socket an class? #2

Open
opened 2026-01-14 03:24:44 +01:00 by mai-lapyst · 2 comments
Owner

Why tf is std.socket.Socket an class to begin with?!?!?! It dosnt uses synchronized that would require the monitor of an class, nor does it holds any significant amount of data: 1 socket_t (32bit fd), an ushort for 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?

Why tf is `std.socket.Socket` an class to begin with?!?!?! It dosnt uses `synchronized` that would require the `monitor` of an class, nor does it holds any significant amount of data: 1 `socket_t` (32bit fd), an `ushort` for 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?
Author
Owner

Decision: we re-type AsyncSocket to an struct.

Decision: we re-type AsyncSocket to an struct.
Author
Owner

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 remoteAddress and localAddress function need it to create the proper address type from it.

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 `remoteAddress` and `localAddress` function need it to create the proper address type from it.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
bithero-dlang/ninox.d-async#2
No description provided.