Skip to content

Conversation

@na-trium-144
Copy link
Contributor

@na-trium-144 na-trium-144 commented Apr 20, 2024

I wanted to use unix domain socket since performance is important in my project, so I implemented based on ipkn/crow#379.
Instead of duplicating App and Server classes, I created wrapper class of acceptor so the existing Server class can be used for unix socket connection.

By specifying socket path with app.unix_path() (instead of app.port(port_num)) the server will create and use that socket instead of listening a tcp socket. (I added example as example/example_unix_socket.cpp)
Although it is named unix socket, this also works on windows.

If there is any problem please let me know.
Especially I am not sure if there is a better name than unix_path(). → renamed to local_socket_path.

@gittiver gittiver requested review from The-EDev and mrozigor April 20, 2024 17:28
@mrozigor
Copy link
Member

mrozigor commented Jun 4, 2024

Maybe rename it if it also works on Windows? Maybe something like external_socket_path or something like this?

@na-trium-144
Copy link
Contributor Author

Actually it is named "unix socket" (or AF_UNIX) on Windows: https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/
But Asio's documentation says it is also known as local sockets, so maybe local_socket_path is ok if "unix" is confusing.
https://think-async.com/Asio/boost_asio_1_18_0/doc/html/boost_asio/overview/posix/local.html

@Dwordcito
Copy link

hi @mrozigor I'm looking to start using this library, but I need this feature, how far are we from having a release with it?

mrozigor
mrozigor previously approved these changes Aug 11, 2024
@mrozigor
Copy link
Member

@Dwordcito after this is merged you could prepare library from the master branch. But I'm not sure when will be the next numbered version available

@gittiver
Copy link
Member

I don't see a use case for pure domain sockets. If you want to use them, maybe http is not the right transport protocol.
Maybe you you should look for fastcgi variants.

@na-trium-144
Copy link
Contributor Author

na-trium-144 commented Aug 12, 2024

In my case my server application is accessed from web browser and also from another client application which internally uses curl, mostly on localhost.
It's possible to use different protocol but it will be easier if I can use http(on tcp) and unix domain socket in the same way.

Curl supports http and websockets via unix domain sockets like curl --unix-socket /path/to/socket.sock http://localhost/some_path, and I also found some examples using http and unix socket using python on stackoverflow
So I think there should be more use cases besides my case.

@Dwordcito
Copy link

The use case is similar to what Docker or Snapd uses today, basically exposing an interface. The part of exposing it through unix sockets is to guarantee securitization at the FS level.

@The-EDev
Copy link
Member

This has been a requested feature since before this fork, @gittiver if this passes all the tests, I think we should merge it into 1.3

The-EDev
The-EDev previously approved these changes Oct 25, 2024
@gittiver
Copy link
Member

gittiver commented Jun 9, 2025

compile fails on windows and linux, maybe caused by using different asio versions?
Could you have a look on the logs?

@gittiver gittiver merged commit fc3a023 into CrowCpp:master Jun 17, 2025
13 checks passed
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