1 /*******************************************************************************
2 
3         copyright:      Copyright (c) 2004 Kris Bell. All rights reserved
4 
5         license:        BSD style: $(LICENSE)
6 
7         version:        Initial release: Aug 2006      
8         
9         author:         Kris
10 
11 *******************************************************************************/
12 
13 module tango.net.InternetAddress;
14 
15 private import tango.net.device.Berkeley;
16 
17 /*******************************************************************************
18 
19 
20 *******************************************************************************/
21 
22 class InternetAddress : IPv4Address
23 {
24         /***********************************************************************
25 
26                 useful for Datagrams
27 
28         ***********************************************************************/
29 
30         this(){}
31 
32         /***********************************************************************
33 
34                 -port- can be PORT_ANY
35                 -addr- is an IP address or host name
36 
37         ***********************************************************************/
38 
39         this (const(char)[] addr, int port = PORT_ANY)
40         {
41                 foreach (int i, char c; addr)
42                          if (c is ':')
43                             {
44                             port = parse (addr [i+1 .. $]);
45                             addr = addr [0 .. i];
46                             break;
47                             }
48 
49                 super (addr, cast(ushort) port);
50         }
51 
52         /***********************************************************************
53 
54 
55         ***********************************************************************/
56 
57         this (uint addr, ushort port)
58         {
59                 super (addr, port);
60         }
61 
62 
63         /***********************************************************************
64 
65 
66         ***********************************************************************/
67 
68         this (ushort port)
69         {
70                 super (port);
71         }
72 
73         /**********************************************************************
74 
75         **********************************************************************/
76 
77         private static int parse (const(char)[] s)
78         {       
79                 int number;
80 
81                 foreach (c; s)
82                          number = number * 10 + (c - '0');
83 
84                 return number;
85         }
86 }