Thread overview
[Issue 818] std.socket.InternetAddress.sin needs to be properly initialized on OS X
Jan 21, 2007
d-bugmail
Jan 29, 2007
d-bugmail
Jan 30, 2007
d-bugmail
Jan 30, 2007
d-bugmail
Mar 09, 2007
d-bugmail
January 21, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=818





------- Comment #2 from thomas-dloop@kuehne.cn  2007-01-21 17:41 -------
# import std.socket, std.stdio;
#
# class Test : InternetAddress{
#    this(){ }
#
#    void check(){
#       ubyte* d = cast(ubyte*)cast(void*)&sin;
#       writefln("%s", d[0 .. sin.sizeof]);
#       writefln("%s", sin.sin_family == AddressFamily.INET);
#    }
# }
#
# void main(){
#    (new Test()).check();
# }

dmd-1.0 / Linux:
> [2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
> true

gdmd-0.21 / Linux:
> [2,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255]
> true


-- 

January 29, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=818


chris@dprogramming.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WORKSFORME




------- Comment #3 from chris@dprogramming.com  2007-01-29 15:06 -------
sockaddr_in's initializer automatically sets these values, perhaps they just
don't in your OS X port.
e.g.
struct sockaddr_in
{
        int16_t sin_family = AF_INET; // Here.
        uint16_t sin_port;
        in_addr sin_addr;
        ubyte[8] sin_zero; // D automatically initializes with 0.
}


-- 

January 30, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=818





------- Comment #4 from d@jeffmcglynn.com  2007-01-29 22:01 -------
On OS X sin_zero is initialized to [0, 255, 255, 255, 255, 255, 255, 255] instead of all-zero.  Using this fixes the EADDRNOTAVAIL errors on my PPC Mac:

class IPAddress : InternetAddress {
        this(char[] addr, ushort port) {
                sin.sin_zero[] = 0;

                super(addr, port);
        }
}


-- 

January 30, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=818


afb@algonet.se changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WORKSFORME                  |




------- Comment #5 from afb@algonet.se  2007-01-30 02:35 -------
This seems to be a bug in the generated configunix.d:
        char[8] sin_zero = [0];

As you are pointing out, it should instead have been:
        ubyte[8] sin_zero = 0;

This is a GDC bug, so that it works in DMD doesn't help. (std.c.windows.socket and std.c.linux.socket uses ubyte)


-- 

March 09, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=818


dvdfrdmn@users.sf.net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED




------- Comment #6 from dvdfrdmn@users.sf.net  2007-03-08 20:08 -------
Fixed in release 0.22


--