Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

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



Location: es_sock.h
Link against: esock.lib

Class RHostResolver

RHostResolver

Support

Supported from 5.0

Description

Provides an interface to host name resolution services, such as DNS, that may be provided by particular protocol modules.

The interface provides functions to access the following facilities:

Note the following points before using this class:

Not all actual services provide all these facilities. You should also consult the documentation on the protocol you are intending to use. Functions return KErrNotSupported if the protocol does not support a given operation. Note that a description of the protocol family name resolution capabilities is available at run-time from TProtocolDesc::iNamingServices.

Derivation

RHostResolverProvides an interface to host name resolution services, such as DNS, that may be provided by particular protocol modules
RSubSessionBaseClient-side handle to a sub-session

Defined in RHostResolver:
Cancel(), Close(), GetByAddress(), GetByName(), GetHostName(), Next(), Open(), SetHostName()

Inherited from RSubSessionBase:
CloseSubSession(), CreateSubSession(), Send(), SendReceive(), SubSessionHandle(), operator=()


Opening and closing


Open()

TInt Open(RSocketServ& aSocketServer,TUint anAddrFamily,TUint aProtocol);

Description

Initialises a name resolution service provided by a particular protocol. It must be called before other object functions are used.

Parameters

RSocketServ& aSocketServer

The socket server session

TUint anAddrFamily

A constant identifying the protocol family

TUint aProtocol

A constant that identifies the protocol that provides the name resolution service

Return value

TInt

KErrNone if successful otherwise another of the system-wide error codes.


Close()

void Close();

Description

Closes a name resolution service. If a service has been opened using Open(), then it should be closed using Close(). This will ensure all associated resources are released.

[Top]


Resolution


GetByAddress()

TInt GetByAddress(const TSockAddr& anAddr,TNameEntry& aResult);
void GetByAddress(const TSockAddr& anAddr,TNameEntry& aResult,TRequestStatus& aStatus);

Description

Gets the name of a host from its address.

Parameters

const TSockAddr& anAddr

The address to use

TNameEntry& aResult

Returns the result of the query. If more than one result is allowed by the protocol, the client can call Next() to find any further results.

TRequestStatus& aStatus

If specified, indicates asynchronous operation and, on completion, contains an error code: see the system-wide error codes.

Return value

TInt

KErrNone if successful otherwise another of the system-wide error codes.


GetByName()

TInt GetByName(const TDesC& aName,TNameEntry& aResult);
void GetByName(const TDesC& aName,TNameEntry& aResult,TRequestStatus& aStatus);

Description

Resolves a machine name to a TSockAddress.

Parameters

const TDesC& aName

The name to resolve. The format of the name and any wild-cards supported, along with any separators in hierarchical name systems, are protocol specific

TNameEntry& aResult

Returns the result of the name resolution. If more than one result is allowed by the protocol, the client can call Next() to find any further results.

TRequestStatus& aStatus

If specified, indicates asynchronous operation and, on completion, contains an error code: see the system-wide error codes.

Return value

TInt

KErrNone if successful otherwise another of the system-wide error codes.


Next()

TInt Next(TNameEntry& aResult);
void Next(TNameEntry& aResult,TRequestStatus& aStatus);

Description

Returns the next answer. For some protocols, GetByName() and GetByAddress() may find more than one answer, for example if aliases are allowed.

Parameters

TNameEntry& aResult

Returns the next result of the name resolution.

TRequestStatus& aStatus

If specified, indicates asynchronous operation and, on completion, contains an error code: see the system-wide error codes.

Return value

TInt

KErrNone if successful otherwise another of the system-wide error codes.

[Top]


Local host


GetHostName()

TInt GetHostName(TDes& aName);
void GetHostName(TDes& aName,TRequestStatus &aStatus);

Description

Gets the name of the local host.

Note that with some protocols the name of the local host is not necessarily known at all times. In some cases, a preceding call to SetHostName() must have been made.

Parameters

TDes& aName

Returns the result of the query. The buffer passed in should have a minimum length of 256 characters, otherwise a panic may occur: you can use a parameter of the THostName type.

TRequestStatus& aStatus

If specified, indicates asynchronous operation and, on completion, contains an error code: see the system-wide error codes.

Return value

TInt

KErrNone if successful otherwise another of the system-wide error codes.


SetHostName()

TInt SetHostName(const TDesC& aName);

Description

Sets the name of the local host.

Parameters

const TDesC& aName

The local host name

Return value

TInt

KErrNone if successful otherwise another of the system-wide error codes.

[Top]


Cancelling


Cancel()

void Cancel();

Description

Cancels any outstanding asynchronous calls, which will return with error code KErrCancel.