sname, name, self, node

One of the things I’ve always been unclear on is how a server binds to particular address. This became apparent today in my erlang-in-lisp work with iolib and erlang itself. I had been messing around with distributing the ping-pong example last week and things were not going as smoothly as I’d initially hoped. It was all coming down to dns, the hosts file, and binding the server to the wrong address. Today I tried the example in erlang, and my mistake became clear when I read up on the behavior of erlang with regards to ‘short names’ and ‘long names’ (it seems erlang is fond of adopting somewhat unusual terminology).

It turns out that some of my thinking last week was unacceptable; I’d been expecting self() to return information that could only be retrieved after a connection to a particular process. This is impossible given the semantics of self(). Furthermore, I’d forgotten about the node() BIF in erlang. By matching the behavior of the sname and name command line parameters in erlang, all has become clear. The user specifies the hostname (or sometimes the IP address) to which the erlang (or erlang-in-lisp) process should be bound. While this may seem a bit tedious at first blush, it really does (along with the cookie system) prevent unsuspecting users from casually opening up erlang processes to the outside world. This will be (has been) duplicated in eil (though there is still a runtime typing problem keeping things from working properly at the moment…hopefully trivial).

Tomorrow I’m planning to swing by Loyola to pick up my ‘alumni card’. I hope it allows me into the library (it should) to check out “Unix Network Programming” as I think this reference will be useful in the coming days. I’m planning to tackle distribution and linking processes simultaneously this week. I’m also hoping to be diligent in writing unit tests as I’ve found myself retyping the same test code at the repl over the last several days.

I’ve also been wondering about an erlang grammar. Does one exist and could be use it in something like a lisp packrat parser? Off to bed now…I hope this post does not sound like gibberish in the morning :)

Comments !