Bug 9384 – std.socket: UnixAddress broken on Linux and others
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-01-24T00:30:00Z
Last change time
2013-09-08T05:43:03Z
Assigned to
nobody
Creator
alanb
Comments
Comment #0 by alanb — 2013-01-24T00:30:51Z
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;
}
}