www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9384] New: std.socket: UnixAddress broken on Linux and others

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9384

           Summary: std.socket: UnixAddress broken on Linux and others
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: alanb ucora.com


--- Comment #0 from Rob T <alanb ucora.com> 2013-01-24 00:30:51 PST ---
std.socket is missing the following import:

import core.sys.posix.sys.un;

Even when adding in the missing import, the implementation of UnixAddress is
broken.

Here's my quick fix for Linux (there may be problems with it), there also needs
to be versions for OSX and FreeBSD because sockaddr_un is slightly different.

import std.c.linux.socket;
import core.sys.posix.sys.un;

class UnixAddress: Address
{
    private:
        sockaddr_un sun;

        this()
        {
        }

    public:

        override  property sockaddr* name()
        {
            return cast(sockaddr*)&sun;
        }

        override  property const(sockaddr)* name() const
        {
            return cast(const(sockaddr)*)&sun;
        }

        override  property socklen_t nameLen() const
        {
            return cast(socklen_t) sun.sizeof;
        }

        this(in char[] path)
        {
            sun.sun_family = AF_UNIX;
            sun.sun_path.ptr[0..path.length] = cast(byte[])path;
            sun.sun_path.ptr[path.length] = 0;
        }

         property string path() const
        {
            return to!string(sun.sun_path.ptr);
        }

        override string toString() const
        {
            return path;
        }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 24 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9384


jerro.public gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |jerro.public gmail.com
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 08 2013