Files
ldc/tango/tango/net/InternetAddress.d
Tomas Lindquist Olsen b15b3484c8 [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.
2008-01-11 17:57:40 +01:00

87 lines
2.4 KiB
D

/*******************************************************************************
copyright: Copyright (c) 2004 Kris Bell. All rights reserved
license: BSD style: $(LICENSE)
version: Initial release: Aug 2006
author: Kris
*******************************************************************************/
module tango.net.InternetAddress;
private import tango.net.Socket;
/*******************************************************************************
*******************************************************************************/
class InternetAddress : IPv4Address
{
/***********************************************************************
useful for Datagrams
***********************************************************************/
this(){}
/***********************************************************************
-port- can be PORT_ANY
-addr- is an IP address or host name
***********************************************************************/
this (char[] addr, int port = PORT_ANY)
{
foreach (int i, char c; addr)
if (c is ':')
{
port = parse (addr [i+1 .. $]);
addr = addr [0 .. i];
break;
}
super (addr, cast(ushort) port);
}
/***********************************************************************
***********************************************************************/
this (uint addr, ushort port)
{
super (addr, port);
}
/***********************************************************************
***********************************************************************/
this (ushort port)
{
super (port);
}
/**********************************************************************
**********************************************************************/
private static int parse (char[] s)
{
int number;
foreach (c; s)
number = number * 10 + (c - '0');
return number;
}
}