Added support for unix sockets#3152
Conversation
How are you making the socket you have when you call |
Co-authored-by: Davis E. King <davis685@gmail.com>
For Fast CGI, you are usually not making the socket. Either systemd or another tool, like spawn-fcgi, will bind a socket to file descriptor 0 (stdin). So, I just pass 0 as the argument to |
Yes, it's easy enough to just create, bind, and listen on a socket to use for the test, but I wasn't sure if putting a bunch of platform specific headers and an I could also add some public function, say Let me know what you prefer, and thanks for reviewing! |
Yeah make some public function that cleanly does it and use that in the tests. That would be sweet. |
|
I believe this is ready now. I added a public function called This also allows for using sockets obtained from external APIs in listener objects. |
I'm working on a Fast CGI server for my ML models and would like to integrate supporting changes into dlib's networking module. One of these changes is supporting socket type AF_UNIX, so web servers like nginx can bypass the network stack when communicating with the fcgi server. Another is a listener factory method that can accept connections on a user-provided socket. In many fast cgi setups, the application is expected to listen on stdin (which is bounded to a socket), so the user-provided socket is helpful here.
I implemented the required changes for both posix and win32 including tests. However, I'm not sure how to test the new
create_listener_from_socketmethod. It would require platform specific code in the unit test.