[erlang-questions] unix domain sockets with abstract namespace: can't use all 108 bytes

Richard A. O'Keefe ok@REDACTED
Mon Mar 27 23:12:05 CEST 2017


> On 28/03/2017, at 5:03 AM, Bekes, Andras G <Andras.Bekes@REDACTED> wrote:
> I need to communicate with unix domain sockets using the abstract namespace and the server (which is not under my control) opens the port with all 108 bytes of the path used.

Be careful there.  OSX 10.11.3 manual page:

    UNIX-domain addresses are variable-length filesystem pathnames 
    of at most 104 characters.

The Single Unix Specification, version 4, section un.h, says

    The size of sun_path has intentionally been left undefined.
    This is because different implementations use different sizes.
    For example, 4.3 BSD uses a size of 108, and 4.4 BSD uses a size of 104.
    Since most implementations originate from BSD versions, the size is
    typically in the range 92 to 108.

    Applications should not assume a particular length for sun_path
    or assume that it can hold {_POSIX_PATH_MAX} bytes (256).

Expect the last byte to be used for the NUL terminator of a C string,
so the length of the actual name could be limited to 91..107.





More information about the erlang-questions mailing list