Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 12 commits into from
May 3, 2021

Conversation

lithdew
Copy link
Contributor

@lithdew lithdew commented Apr 30, 2021

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 storing/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. NOSIGPIPE).

@lithdew
Copy link
Contributor Author

lithdew commented Apr 30, 2021

Noticed some errors from Azure CI. Gonna sign off for today and fix them tomorrow.

@lithdew lithdew force-pushed the master branch 2 times, most recently from 6961e38 to 981dbc3 Compare May 2, 2021 09:51
@andrewrk
Copy link
Member

andrewrk commented May 2, 2021

Rebasing on master should fix the freebsd CI issue

lithdew added 12 commits May 3, 2021 14:49
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).
Address comments from @ifreund and @MasterQ32 to address unsafeness and
ergonomics of the `Address` API.

Rename the `TCP` namespace to `tcp` as it does not contain any
top-level fields.

Fix missing reference to `sockaddr` which was identified by @kprotty in
os/bits/linux/arm64.zig.
Use i32 instead of isize for os.timeval's for socket read/write
timeouts.

Add a comptime check to resolveScopeID to see if `IFNAMESIZE` is
available on the host. If it is not available, return an error
indicating that resolving the scope ID of a IPv6 address is not yet
supported on the host platform.
Generalize `tcp.Address` into `ip.Address` given that multiple transport
protocols apart from TCP (i.e. UDP) operate solely over IP.
@lithdew
Copy link
Contributor Author

lithdew commented May 3, 2021

Got CI passing all tests 😄.

@andrewrk andrewrk merged commit 0e3930b into ziglang:master May 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants