Skip to content

Conversation

kouhe3
Copy link
Contributor

@kouhe3 kouhe3 commented Oct 4, 2025

r? rust-lang/libs-api

Summary

This PR adds Unix-domain socket support to the Windows port of the standard library,
mirroring the existing APIs in std::os::unix::net.
The implementation is gated behind the unstable feature windows_unix_domain_sockets;
track issue #56533 .

Motivation / Background

Windows 10 17063+ officially support AF_UNIX.
Having the same UnixStream / UnixListener surface on Windows removes the need for
crates such as mio-uds-windows and lets cross-platform code use a single API.

Acknowledgements

99 % of the code was transplanted from
https://github.com/Azure/mio-uds-windows
(thank you @damonbarry ).
The main delta is switching from the winapi crate to the std.

What is added

module public items
std::os::windows::net UnixStream, UnixListener, SocketAddr, sockaddr_un

All types mirror their Unix counterparts and implement the usual
Read+Write, AsRawSocket/FromRawSocket/IntoRawSocket, AsSocket, etc.

Feature gate

#![cfg(all(windows, feature = "windows_unix_domain_sockets"))]
#![unstable(feature = "windows_unix_domain_sockets", issue = "56533")]

Testing

Can't run test because rustc ICE

How to try it locally

$ git checkout <your-branch>
$ ./x.py build library --stage 1
$ ./x.py test library/std/tests/net/windows_unix_socket.rs
#![feature(windows_unix_domain_sockets)]
use std::os::windows::net::UnixListener;

Notes for reviewers

  • No unsafe blocks outside sys::pal::windows.
  • All unsafe is restricted to WSASocketW, bind, connect, getsockname, getpeername.
  • sockaddr_un construction follows the Unix implementation: zero-init, copy path, null-term.
  • Drop impl is reused from sys::net::Socket, so closesocket always runs.

Commit message

std::os::windows::net: initial Unix-domain socket support
Adds unstable `windows_unix_domain_sockets` feature that exposes
`UnixStream` and `UnixListener` on Windows 10 17063+.

Code is largely taken from Azure/mio-uds-windows
Co-authored-by: kouhe3
Acked-by: 

Checklist before clicking “Create pull request”

  • ./x.py fmt – clean
  • ./x.py test library/std/tests/net/windows_unix_socket.rs – blocked
  • ./x.py test library/std --stage 1 – blocked

Blocked reason:

The bootstrap rustc (stage0) crashes with STATUS_ACCESS_VIOLATION when compiling core during the test phase

@rustbot rustbot added O-windows Operating system: Windows S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Oct 4, 2025
@rustbot

This comment has been minimized.

@rustbot rustbot added has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 4, 2025
@kouhe3 kouhe3 changed the title Win af unix std::os::windows::net: add Unix-domain socket support (AF_UNIX on Windows) Oct 4, 2025
@rustbot rustbot removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. has-merge-commits PR has merge commits, merge with caution. labels Oct 4, 2025
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Oct 4, 2025

☔ The latest upstream changes (presumably #147340) made this pull request unmergeable. Please resolve the merge conflicts.

@rustbot
Copy link
Collaborator

rustbot commented Oct 5, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-windows Operating system: Windows S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants