I did not know about that feature. Interesting. Also interesting that it's
not supported on OSX.

That said, I still think Unix domain sockets are good in this case. There
are just a few things that needs to be done in order to make them solid. I
think I did most of those things in the native code for the Emacs mode.

These things include:

   - Call unlink() on the socket file before creating it (in case there is
   one lingering from before).
   - Call unlink() on the socket when shitting down (we want everything to
   be clean after shutdown).
   - When automatically starting the backend (as opposed to manually
   creating it), compute the filename so that it's reasonably unique. I.e.
   append the process ID to it or something.

What do you think of this?

Regards,
Elias


On 24 July 2014 19:26, Juergen Sauermann <juergen.sauerm...@t-online.de>
wrote:

>  Hi Elias,
>
> the idea is this:
>
> man 7 unix says:
>
>  *abstract:  an  abstract  socket address is distinguished by the fact*
> *          that sun_path[0] is a null byte ('\0').   The  socket's
> address  in*
> *          this namespace is given by the additional bytes in sun_path
> that are*
> *          covered by the specified length of  the  address  structure.
> (Null*
> *          bytes  in  the  name have no special significance.)*
>
> So I *memset()* the entire socket address first and then copy the name to
> *sun_path,*
> but starting at  *sun_path[1]* so that *sun_path[0]* remains *0 *(making
> it an abstract
> socket).
>
> man 7 unix also says:
>
> * The abstract socket namespace is a nonportable Linux extension.*
>
> That's why I *#define ABSTRACT_OFFSET* to 1 if your OS supports it and
> you can change it to 0 if not. In the latter case you have to provide a
> file
> */tmp/GNU-APL/APserver* manually with proper permissions.
>
> This file is having the file permissions that you were after earlier. I am
> not creating that file because I expect more problems with it than benefits
> (who owns it, who installs it, what if one user creates it with wrong
> permissions etc.).
>
> My general feeling is that TCP on localhost is much cleaner and maybe I
> should make
> that the default.
>
> /// Jürgen
>
>
>
> On 07/24/2014 12:59 PM, Elias Mårtenson wrote:
>
> Sorry, I accidentally hit send… Here's the rest:
>
>  In the following call can be found in bot Svar_DB.cc and the APserver,
> you can find the following:
>
>      strcpy(remote.sun_path + ABSTRACT_OFFSET, server_sockname);
>
>  ABSTRACT_OFFSET is #defined to 1. This means that the first character of
> the path will be 0 (there is a memset() before), and of course the call
> to bind() will fail.
>
>  Removing the addition of ABSTRACT_OFFSET will fix the problem.
>
>  I've been looking at the code and I have been trying to figure out why
> the code was written in this way to begin with. Any ideas?
>
>  Regards,
> Elias
>
>
>  On 24 July 2014 18:55, Elias Mårtenson <loke...@gmail.com> wrote:
>
>> I had never been able to get APserver to work properly, and particularly
>> not with the Unix Domain Sockets.
>>
>>  But, I finally figured it out. :-)
>>
>>  In the following call can be found in bot Svar_DB.cc and the APserver.
>>
>
>
>

Reply via email to