Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changeset 1543

Show
Ignore:
Timestamp:
05/23/10 08:09:59 (15 years ago)
Author:
rsinfu
Message:

Fixed bugzilla 2835: std.socket.TcpSocket? doesn't actually connect.
Thanks to Unknown W. Brackets and Alexey Ivanov for the patch!

sockaddr_in.sin_family is auto-initialized with AF_INET only on Windows
(compare std.c.windows.winsock & core.sys.posix.netinet.in_). TcpSocket?
should explicitly set sin_family to AF_INET.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/phobos/std/socket.d

    r1513 r1543  
    724724        uint uiaddr = parse(addr); 
    725725        if(ADDR_NONE == uiaddr) 
    726726        { 
    727727            InternetHost ih = new InternetHost; 
    728728            if(!ih.getHostByName(addr)) 
    729729                //throw new AddressException("Invalid internet address"); 
    730730                            throw new AddressException( 
    731731                                 "Unable to resolve host '" ~ addr ~ "'"); 
    732732            uiaddr = ih.addrList[0]; 
    733733        } 
     734        sin.sin_family = AddressFamily.INET; 
    734735        sin.sin_addr.s_addr = htonl(uiaddr); 
    735736        sin.sin_port = htons(port); 
    736737    } 
    737738 
    738739    /** 
    739740     * Construct a new Address. addr may be ADDR_ANY (default) and port may 
    740741     * be PORT_ANY, and the actual numbers may not be known until a connection 
    741742     * is made. 
    742743     */ 
    743744    this(uint addr, ushort port) 
    744745    { 
     746        sin.sin_family = AddressFamily.INET; 
    745747        sin.sin_addr.s_addr = htonl(addr); 
    746748        sin.sin_port = htons(port); 
    747749    } 
    748750 
    749751    /// ditto 
    750752    this(ushort port) 
    751753    { 
     754        sin.sin_family = AddressFamily.INET; 
    752755        sin.sin_addr.s_addr = 0; //any, "0.0.0.0" 
    753756        sin.sin_port = htons(port); 
    754757    } 
    755758 
    756759    /// Human readable string representing the IPv4 address in dotted-decimal form. 
    757760    string toAddrString() 
    758761    { 
    759762            return to!string(inet_ntoa(sin.sin_addr)).idup; 
    760763    } 
    761764