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, x/os/Socket: initial work on new Socket abstraction #8590

Merged
merged 2 commits into from
Apr 25, 2021

Conversation

lithdew
Copy link
Contributor

@lithdew lithdew commented Apr 21, 2021

Kick-start initial work on new cross-platform abstraction for sockets. Adds a test for read timeouts and a test for creating a non-blocking socket pair on Linux.

The new Socket abstraction is barebones and is made to support both blocking and non-blocking abstractions, alongside different socket protocols and domains.

Support for platform-dependent socket options that handle unsupported platforms gracefully via. comptime checks are provided for the new Socket abstraction.

This also marks the first out of many commits for introducing breaking changes to the standard library in a separate x package folder, which was pre-approved by @andrewrk.

The intent for the new x package is to introduce new async, event loop, networking, and operating system abstractions that would require breaking the standard library significantly. By having the x package, code in the standard library and compiler may then slowly be refactored to use the x package. Once modules in the x package are stabilized, they can be moved out of the x package, and a global 'grep' can be done to update import paths that resolve to the stabilized module in the x package.

This also kickstarts addressing #6600. Happy to fix minor things that should be addressed throughout the code in this PR; otherwise a subsequent PR might be better.

@LemonBoy
Copy link
Contributor

You may be interested in #7844 and its related issue too.

@lithdew
Copy link
Contributor Author

lithdew commented Apr 21, 2021

You may be interested in #7844 and its related issue too.

Yep! Really like the layout of the API; my thoughts were to branch out TCP and UDP abstractions from this generic Socket abstraction (i.e. TcpListener and TcpClient, or TCP.Listener and TCP.Client).

lib/std/x.zig Outdated Show resolved Hide resolved
@lithdew
Copy link
Contributor Author

lithdew commented Apr 22, 2021

Rebased with master to re-run CI checks.

Kick-start initial work on new cross-platform abstraction for
sockets. Adds a test for read timeouts and a test for creating
a non-blocking socket pair on Linux.

The new Socket abstraction is barebones and is made to support both
blocking and non-blocking abstractions, alongside different socket
protocols and domains.

Support for platform-dependant socket options that handles unsupported
platforms gracefully via. comptime checks is provided for the new Socket
abstraction.

This also marks the first out of many commits for introducing breaking
changes to the standard library in a separate `x` folder, which was
pre-approved by @andrewrk.

The intent for the new `x` package is to introduce new async, event loop,
networking, and operating system abstractions that would require breaking
the standard library significantly. By having the `x` package, code in the
standard library and compiler may then slowly be refactored to use the `x`
package. Once modules in the `x` package are stabilized, they can be moved
out of the `x` package, and a global 'grep' can be done to update import
paths that resolve to the stabilized module in the `x` package.
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