Changeset 1543
- Timestamp:
- 05/23/10 08:09:59 (15 years ago)
- Files:
-
- trunk/phobos/std/socket.d (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/phobos/std/socket.d
r1513 r1543 724 724 uint uiaddr = parse(addr); 725 725 if(ADDR_NONE == uiaddr) 726 726 { 727 727 InternetHost ih = new InternetHost; 728 728 if(!ih.getHostByName(addr)) 729 729 //throw new AddressException("Invalid internet address"); 730 730 throw new AddressException( 731 731 "Unable to resolve host '" ~ addr ~ "'"); 732 732 uiaddr = ih.addrList[0]; 733 733 } 734 sin.sin_family = AddressFamily.INET; 734 735 sin.sin_addr.s_addr = htonl(uiaddr); 735 736 sin.sin_port = htons(port); 736 737 } 737 738 738 739 /** 739 740 * Construct a new Address. addr may be ADDR_ANY (default) and port may 740 741 * be PORT_ANY, and the actual numbers may not be known until a connection 741 742 * is made. 742 743 */ 743 744 this(uint addr, ushort port) 744 745 { 746 sin.sin_family = AddressFamily.INET; 745 747 sin.sin_addr.s_addr = htonl(addr); 746 748 sin.sin_port = htons(port); 747 749 } 748 750 749 751 /// ditto 750 752 this(ushort port) 751 753 { 754 sin.sin_family = AddressFamily.INET; 752 755 sin.sin_addr.s_addr = 0; //any, "0.0.0.0" 753 756 sin.sin_port = htons(port); 754 757 } 755 758 756 759 /// Human readable string representing the IPv4 address in dotted-decimal form. 757 760 string toAddrString() 758 761 { 759 762 return to!string(inet_ntoa(sin.sin_addr)).idup; 760 763 } 761 764
