-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Unix Domain Sockets #120
Conversation
(cherry picked from commit c00a559)
I am merging this: this is clean extension code in a separate package. I wil now try to run it myself. |
(continuing our email conversation) Netcat is nc, I think it is standard on macOS and Linux. I was able to start a server using
and connect to it using
just type something and hit return. Here are some links with more info
This is not enough to build a real unit test, but it should allow users to run something. |
Now, when I try the above, I get an error: it seems the method Is that something you added and forgot to include ? |
OK, with the missing connectTo: method I can run the code, I can connect with the client to a unix socket (provided I own it) on macOS. The HTTP comes through, but I need to figure out how to answer. |
Thank you! Do you think that we can make the |
I don't know. But the first problem is that I think something is wrong with the reading part in Pharo. If you try with the nc/telnet example (BTW, you have to delete the socket to start over), you can send data from telnet to nc and back. The following would be a correct HTTP response:
which goes back to telnet, but never to Pharo. Oh, you also need a unix socket that you own yourself. Are you sure reading works ? It seems to be stuck in waiting for data. |
BTW: The Unix Socket implementation is taken from here: https://samadhiweb.com/blog/2013.07.27.unixdomainsockets.html |
Ah OK, that is great. I guess it should be possible to run nginx locally, serving on a unix domain socket. I would like to see that first. |
I am on Pharo 11 I had to use a socket like this /Users/sven/tmp/test.sock (one that is owned by my user) I am trying to configure nginx under brew BTW |
I got it to work! Installed nginx via brew and edited /usr/local/etc/nginx/nginx.conf
Now I can do
and I get HTML back.
And I get the same HTML. Now we can start thinking about the server side, maybe simple socket server would better to start with. I am still not sure how the socket permissions have to be. |
But now that I am home, I also get a NetNameResolver error, where it worked before. So maybe somehow this works only once. Restarting the image does not help. |
OK, I think I found it, NetNameResolver initializeNetwork is missing (see the last comment at the end of https://samadhiweb.com/blog/2013.07.27.unixdomainsockets.html) |
I see. Will you commit the change in BTW. Now it works for me in both, Pharo 10 and 11. |
I did a small refactoring (as per the blog post), it feels cleaner to me. Sven |
Hi @svenvc, thank you for the refactoring. It looks better now. Juraj |
Introduction
The aim of the presented changes is to be able to communicate with HTTP servers over Unix Domain Sockets.
For example to communicate with a Docker Engine, the following code can be executed from a terminal:
This pull request implements a
ZnUnixSocketClient
that can be used as follows:ZnUnixSocketClient
is a subclass ofZnClient
and placed in aZinc-HTTP-UnixSocket
package.Implementation details
ZnUnixSocketClient
ZnUnixSocketClientTest
Zinc-HTTP-UnixSocket
package to a baseline.