# x/os, x/net: layout tcp, ipv4/ipv6, and socket abstractions · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/2ab588049e41a96337a4fa8c2d9507320bc4278b)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 2ab588049e41a96337a4fa8c2d9507320bc4278b

Requested commit: 2ab588049e41a96337a4fa8c2d9507320bc4278b

Commit: 2ab588049e41a96337a4fa8c2d9507320bc4278b

Tree: d4958fc71559cdd4f4c3bd5952e266bfe1dd4499

Author: lithdew

Committer: lithdew

## Message

```
x/os, x/net: layout tcp, ipv4/ipv6, and socket abstractions

The `Socket` abstraction was refactored to only comprise of methods that
can be generically used/applied to all socket domains and protocols.

A more comprehensive IPv4/IPv6 module derived from @LemonBoy's earlier
work was implemented under `std.x.os.IPv4` and `std.x.os.IPv6`. Using
this module, one can then combine them together into a union for example
in order to optimize memory usage when dealing with socket addresses.

A `TCP.Client` and `TCP.Listener` abstraction is introduced that is one
layer over the `Socket` abstraction, which isolates methods that can
only be applied to a "client socket" and a "listening socket". All prior
tests from the `Socket` abstraction, which all previously operated
assuming the socket is operating via. TCP/IP, were moved. All TCP socket
options were also moved into the `TCP.Client` and `TCP.Listener`
abstractions respectively away from the `Socket` abstraction.

Some additional socket options from @LemonBoy's prior PR for Darwin were
also moved in (i.e. SIGNOPIPE).

```

## Parents

- [c47028cd025f4ce405a9395fa979ff14a3e6349a](https://git.cafe/gitcafe/zig/commit/c47028cd025f4ce405a9395fa979ff14a3e6349a?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/2ab588049e41a96337a4fa8c2d9507320bc4278b?format=markdown)
