Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In which way can i make use of AF_UNIX defined in Winsock2 in Windows

I have tried AF_UNIX with Windows socket API as follows:

socket(AF_UNIX, SOCK_STREAM, 0);

Above call returned INVALID_SOCKET. Last error was:

10047 "An address incompatible with the requested protocol was used".

The results were same when i tried the same with other socket 'type' values available in Windows like SOCK_DGRAM and SOCK_RAW.

So my question is: Is there any way to make use of AF_UNIX defined in 'Winsock2', so that its functionality similar to that in UNIX can be achieved here in Windows?

like image 454
Aravind Avatar asked Dec 04 '25 18:12

Aravind


2 Answers

The documentation on MSDN for the socket function says:

The values currently supported are AF_INET or AF_INET6, which are the Internet address family formats for IPv4 and IPv6. Other options for address family (AF_NETBIOS for use with NetBIOS, for example) are supported if a Windows Sockets service provider for the address family is installed.

So, unless you have installed a third-party service provider, you cannot use AF_UNIX.

like image 187
Harry Johnston Avatar answered Dec 06 '25 09:12

Harry Johnston


I know this post is old, but in 2017 AF_UNIX was added to Windows 10! (I believe it was because of the WSL, but that's just my speculation).

But in summary, you'll need to use the #include <afunix.h> header.

For more information:

AF_UNIX comes to Windows

The unix socket (AF_UNIX) function in Windows

like image 36
Gabriel Frigo Avatar answered Dec 06 '25 07:12

Gabriel Frigo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!