Skip to content

gio: Add some AF_UNIX support on Windows

Marc-André Lureau requested to merge malureau/glib:win32-afunix into main

Teach GIO to handle AF_UNIX sockets on Windows.

AF_UNIX are available in Windows 10 since Build 17063. The have a number of limitations compared to other POSIX/BSD socket implementations (in particular, no SCM_RIGHTS, and very limited credential passing). However, they are quite attractive as an alternative to opening a local TCP port for local socket communications (and DBus), as they should be more secure and not directly reachable from a web browser! Looking up peer process id is also simpler and a bit safer than with TCP sockets.

There are also interesting use cases that possibles, since they can communicate with WSL2 systems.

For testing purposes, I implemented a _g_win32_socketpair() (similar to the ocaml implementation from https://github.com/ocaml-multicore/ocaml-multicore/blob/5.00/otherlibs/win32unix/socketpair.c). I wish this function could be provided publicly by glib, since it's fairly common to want it in various projects for inter-thread communications, or testing. What do you think? There is no WSAError to errno conversion at this point. Perhaps the function could use GError instead.

Fixes: #2487 (closed)

Merge request reports