Changeset 1548
- Timestamp:
- 05/23/10 23:40:02 (15 years ago)
- Files:
-
- branches/phobos-1.x/phobos/std/socket.d (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/phobos-1.x/phobos/std/socket.d
r1539 r1548 686 686 uint uiaddr = parse(addr); 687 687 if(ADDR_NONE == uiaddr) 688 688 { 689 689 InternetHost ih = new InternetHost; 690 690 if(!ih.getHostByName(addr)) 691 691 //throw new AddressException("Invalid internet address"); 692 692 throw new AddressException( 693 693 "Unable to resolve host '" ~ addr ~ "'"); 694 694 uiaddr = ih.addrList[0]; 695 695 } 696 sin.sin_family = AddressFamily.INET; 696 697 sin.sin_addr.s_addr = htonl(uiaddr); 697 698 sin.sin_port = htons(port); 698 699 } 699 700 700 701 /** 701 702 * Construct a new Address. addr may be ADDR_ANY (default) and port may 702 703 * be PORT_ANY, and the actual numbers may not be known until a connection 703 704 * is made. 704 705 */ 705 706 this(uint addr, ushort port) 706 707 { 708 sin.sin_family = AddressFamily.INET; 707 709 sin.sin_addr.s_addr = htonl(addr); 708 710 sin.sin_port = htons(port); 709 711 } 710 712 711 713 /// ditto 712 714 this(ushort port) 713 715 { 716 sin.sin_family = AddressFamily.INET; 714 717 sin.sin_addr.s_addr = 0; //any, "0.0.0.0" 715 718 sin.sin_port = htons(port); 716 719 } 717 720 718 721 /// Human readable string representing the IPv4 address in dotted-decimal form. 719 722 string toAddrString() 720 723 { 721 724 return std.string.toString(inet_ntoa(sin.sin_addr)).dup; 722 725 } 723 726
