Mercurial > projects > ldc
comparison tango/tango/net/InternetAddress.d @ 132:1700239cab2e trunk
[svn r136] MAJOR UNSTABLE UPDATE!!!
Initial commit after moving to Tango instead of Phobos.
Lots of bugfixes...
This build is not suitable for most things.
author | lindquist |
---|---|
date | Fri, 11 Jan 2008 17:57:40 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
131:5825d48b27d1 | 132:1700239cab2e |
---|---|
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.Socket; | |
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 (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 (char[] s) | |
78 { | |
79 int number; | |
80 | |
81 foreach (c; s) | |
82 number = number * 10 + (c - '0'); | |
83 | |
84 return number; | |
85 } | |
86 } |