Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Location: in_sock.h
Link against: insock.lib

Class TInetAddr

TInetAddr

Support

Supported from 5.0

Description

TCP/IP address.

This class specialises the generic socket server address class TSockAddr for the TCP/IP protocol family. The class stores an IP address as a TUint32 in its buffer after the generic data defined by TSockAddr. The protocol family field provided by the TSockAddr base class is always set to KAfInet (TCP/IP).

Derivation

TBuf8This is a descriptor class which provides a buffer of fixed length for containing, accessing and manipulating TUint8 data
TBufBase8Base class used in the derivation of TBuf8
TDes8Modifiable 8-bit descriptor; abstract class
TDesC8Abstract base class for 8 bit non-modifiable descriptors
TInetAddrTCP/IP address
TSockAddrRepresents an end point address

Defined in TInetAddr:
Address(), Cast(), CmpAddr(), Input(), IsBroadcast(), IsClassA(), IsClassB(), IsClassC(), IsMulticast(), IsWildAddr(), IsWildPort(), Match(), Net(), NetBroadcast(), NetMask(), Output(), SetAddress(), SubNet(), SubNetBroadcast(), TInetAddr()

Inherited from TBuf8:
operator=()

Inherited from TDes8:
Append(), AppendFill(), AppendFormat(), AppendFormatList(), AppendJustify(), AppendNum(), AppendNumFixedWidth(), AppendNumFixedWidthUC(), AppendNumUC(), Capitalize(), Collate(), Copy(), CopyC(), CopyCP(), CopyF(), CopyLC(), CopyUC(), Delete(), Fill(), FillZ(), Fold(), Format(), FormatList(), Insert(), Justify(), LowerCase(), MaxLength(), MaxSize(), Num(), NumFixedWidth(), NumFixedWidthUC(), NumUC(), PtrZ(), Repeat(), Replace(), SetLength(), SetMax(), Swap(), Trim(), TrimAll(), TrimLeft(), TrimRight(), UpperCase(), Zero(), ZeroTerminate(), operator+=(), operator=, operator[]()

Inherited from TDesC8:
Alloc(), AllocL(), AllocLC(), Compare(), CompareC(), CompareF(), Find(), FindC(), FindF(), Left(), Length(), Locate(), LocateF(), LocateReverse(), LocateReverseF(), MatchC(), MatchF(), Mid(), Ptr(), Right(), Size(), operator!=(), operator<(), operator<=(), operator==(), operator>(), operator>=()

Inherited from TSockAddr:
CmpPort(), Family(), GetUserLen(), Port(), SetFamily(), SetPort(), SetUserLen(), UserPtr()


Construction


TInetAddr()

TInetAddr();

Description

Constructs a basic TInetAddr. The port is initialised to 0, and the IP address to KInetAddrNone.


TInetAddr()

TInetAddr(TUint aPort);

Description

Constructs a TInetAddr and initialises the port to the specified value, and the IP address to KInetAddrNone.

Parameters

TUint aPort

Value to which to set the port.


TInetAddr()

TInetAddr(TUint32 anAddr, TUint aPort);

Description

Constructs a TInetAddr and initialise the specified port value to and the IP address to anAddr.

Parameters

TUint32 anAddr

Value to which to set the IP address.

TUint aPort

Value to which to set the port.


TInetAddr()

TInetAddr(const TSockAddr& anAddr);

Description

Constructs a TInetAddr from another TInetAddr that has been downcast to a TSockAddr. The port and IP address values are copied from anAddr.

Parameters

const TSockAddr& anAddr

TSockAddr from which to copy port and IP address values.

[Top]


IP address


SetAddress()

void SetAddress(TUint32 anAddr);

Description

Sets the IP address value. An IP address in dotted-decimal form can be converted into a TUint32 by the INET_ADDR macro.

Parameters

TUint32 anAddr

Value to which to set the IP address.


Address()

TUint32 Address() const;

Description

Gets the IP address value.

Return value

TUint32

The IP address value

[Top]


Comparisons


CmpAddr()

TBool CmpAddr(const TInetAddr& anAddr) const;

Description

Tests the protocol family, IP address, and port values with those in another TInetAddr.

Parameters

const TInetAddr& anAddr

TInetAddr with which to compare.

Return value

TBool

ETrue if protocol family, IP address, and port values are the same, otherwise EFalse.


Match()

TBool Match(const TInetAddr aHost) const;

Description

Tests the IP address value with that in another TInetAddr.

Parameters

const TInetAddr aHost

TInetAddr with which to compare.

Return value

TBool

ETrue if IP address values are the same, otherwiseEFalse.


Match()

TBool Match(const TInetAddr aNet, const TInetAddr aMask) const;

Description

Tests if another TInetAddr is in the same subnet. The function applies the subnet mask passed through aMask to the IP address and to the IP address in aNet. If the resulting values are the same, this indicates that the addresses are part of the same subnet, andETrue is returned.

Parameters

const TInetAddr aNet

TInetAddr with which to compare.

const TInetAddr aMask

TInetAddr object with the IP address set to the relevant subnet mask.

Return value

TBool

ETrue if both IP address values are the members of the same subnet, otherwise EFalse.

[Top]


Input/output


Input()

TInt Input(const TDesC& aBuf);    

Description

Sets the IP address from a string containing a representation of an IP address, such as might be entered in a dialog. The string must contain an ASCII representation of one of the following:

Parameters

const TDesC &aBuf

Descriptor containing a string representation of an IP address

Return value

TInt

KErrNone, otherwise another of the system-wide error codes..


Output()

void Output(TDes &aBuf) const;

Description

Writes the IP address into a string in dotted-decimal form.

Parameters

TDes &aBuf

On return, contains a string representation of the IP address in dotted-decimal form

[Top]


Address parts


NetMask()

void NetMask(const TInetAddr& aAddr);

Description

Sets the IP address to a mask suitable for extracting the network number part of the IP address. The function tests whether the IP address inaAddr is a Class A, B, C, or other address. It then sets the IP address to suitable mask values as follows:

Parameters

const TInetAddr& aAddr

TInetAddr from which to obtain IP address.


Net()

void Net(const TInetAddr& aAddr);

Description

Obtains a network mask corresponding to the class of the IP address, using the NetMask() function. It then applies this mask to the current IP address.

Parameters

const TInetAddr& aAddr

TInetAddr from which to obtain IP address for creating the network mask.


SubNet()

void SubNet(const TInetAddr& aAddr, const TInetAddr& aMask);

Description

Sets the IP address to the network number and subnet parts of the IP address (that is, the original IP address with the host number part cleared). This is obtained by applying the mask value in aMask to the IP address in aAddr.

Parameters

const TInetAddr& aAddr

TInetAddr from which to obtain IP address.

const TInetAddr& aMask

TInetAddr object with the IP address set to the relevant subnet mask.


NetBroadcast()

void NetBroadcast(const TInetAddr& aAddr);

Description

Sets the IP address to be suitable for a network-directed broadcast address.

The function obtains a network mask corresponding to the class of the IP address in aAddr, using the NetMask() function. It then applies this mask to the current IP address to separate the network number part of the address. The mask is then used again to set all host number bits to 1 (which signifies, broadcast to all hosts on the network).

Parameters

const TInetAddr& aAddr

TInetAddr from which to obtain IP address for creating the network mask.


SubNetBroadcast()

void SubNetBroadcast(const TInetAddr& aAddr, const TInetAddr& aMask);

Description

Sets the IP address to be suitable for a subnet-directed broadcast address. To achieve this, the subnet mask value in aMask is applied to the IP address in aAddr. The mask is then used again to set all host number bits to 1 (which signifies, broadcast to all hosts on the subnet).

Parameters

const TInetAddr& aAddr

TInetAddr from which to obtain IP address.

const TInetAddr& aMask

TInetAddr object with the IP address set to the relevant subnet mask.

[Top]


Address type tests


IsClassA()

TBool IsClassA();

Description

Tests if the IP address is Class A.

Return value

TBool

ETrue if the IP address value is Class A, otherwiseEFalse.


IsClassB()

TBool IsClassB();

Description

Tests if the IP address is Class B.

Return value

TBool

ETrue if the IP address value is Class B, otherwiseEFalse.


IsClassC()

TBool IsClassC();

Description

Tests if the IP address is Class C.

Return value

TBool

ETrue if the IP address value is Class C, otherwiseEFalse.


IsMulticast()

TBool IsMulticast();

Description

Tests if the IP address is Class D (multicast).

Return value

TBool

ETrue if the IP address value is Class D, otherwiseEFalse.


IsBroadcast()

TBool IsBroadcast();

Description

Tests if the IP address is a limited broadcast address (255.255.255.255).

Return value

TBool

ETrue if the IP address value is a limited broadcast address, otherwise EFalse.


IsWildAddr()

TBool IsWildAddr();

Description

Tests if the IP address is zero (0.0.0.0).

Return value

TBool

ETrue if the IP address value is zero, otherwiseEFalse.


IsWildPort()

TBool IsWildPort();    

Description

Tests if the port is zero.

Return value

TBool

ETrue if the port is zero, otherwise EFalse.

[Top]


Casting


Cast()

static TInetAddr& Cast(const TSockAddr& anAddr);

Description

Casts a TSockAddr to a TInetAddr reference. The cast is only safe if the object being referenced is actually aTInetAddr.

Parameters

const TSockAddr& anAddr

TSockAddr to cast.

Return value

TInetAddr&

Casted reference to a TInetAddr.


Cast()

static TInetAddr& Cast(const TSockAddr* anAddr);

Description

Casts a pointer to a TSockAddr to a TInetAddrreference. The cast is only safe if the object to which anAddrpoints to is actually a TInetAddr.

Parameters

const TSockAddr* anAddr

TSockAddr to cast.

Return value

TInetAddr&

Casted pointer to a TInetAddr.