[Issue 9384] New: std.socket: UnixAddress broken on Linux and others
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jan 24 00:30:52 PST 2013
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 at puremagic.com
ReportedBy: alanb at ucora.com
--- Comment #0 from Rob T <alanb at 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: -------
More information about the Digitalmars-d-bugs
mailing list