I have written following code for Symbian 8.0a to establish GPRS connection using RConnection and after establishing connection retrieve the IP address. The GPRS connection is established successfully on the device but I am not able to get IP address, it shows "::1". Please tell me how to retreive IP address properly.


TInt CGPRSConnector::CreateConnection()
/**
Creates a GPRS Connection using RConnection.
@return SUCCESS if connection is opened successfully ,otherwise one of the error codes if connection failed.
*/
{
TInt lResult = FAILURE;
if ( iIsConnecting )
{
lResult = KErrAlreadyActive;
}
else
{
iIsConnecting = ETrue;
lResult = iSocketServer.Connect();
if(lResult == KErrNone)
{
lResult = iConnection.Open(iSocketServer);

if (lResult == KErrNone)
{
iConnection.Start(iStatus);
iState = EGPRSInProgress;
SetActive();
lResult = SUCCESS;
}
}
}
return lResult;
}


void CGPRSConnector::RunL()
/**
Handles an active object’s request completion event.
*/
{
TInt lResult = FAILURE;
TNifProgress lNifprogress;

switch (iStatus.Int())
{
case KErrNone:
case KErrAlreadyExists: // Connection already exists
{
lResult = SUCCESS;
iState = EGPRSConnected;
iObserver->HandleCallback(EGPRSConnectionEstablished,lResult);
}
break;

default:
{
lResult = KErrNoActiveConnection;
TerminateConnection();
iObserver->HandleCallback(EGPRSConnectionFailed,lResult);
}
break;
}
}

EXPORT_C TInt CGPRSConnector :: TerminateConnection()
/**
Terminates GPRS Connection.
@internalAll
@return SUCCESS if connection is closed successfully ,otherwise one of the error codes.
*/
{
TInt lResult = FAILURE;

Cancel();

if (iIsConnecting)
{
iConnection.Close();
iSocketServer.Close();
iState = EGPRSClosed;
lResult = SUCCESS;
iIsConnecting = EFalse;
}
else
{
lResult = KErrNoActiveConnection;
}
return lResult;
}


void CGPRSConnector:: DoCancel()
/**
Implements cancellation of an outstanding request.
*/
{
}

EXPORT_C CGPRSConnector::~CGPRSConnector()
/**
Destructor of CGPRSConnector Class.
*/
{
Cancel();
}

EXPORT_C TInt CGPRSConnector::RetrieveLocalIPAddress(TDes& aHostName)
{
TInt lResult = SUCCESS;
TRequestStatus lStatus;
TBuf<KIpAddressSize> lHostName;
lHostName.FillZ();

if( IsActive())
{
lResult = KErrNoActiveConnection;
}
else
{
// Initiate DNS
lResult = iHostResolver.Open(iSocketServer,KAfInet,KProtocolInetUdp);
if (KErrNone == lResult)
{
TNameEntry lNameEntry;
TNameRecord lNameRecord;
// DNS request for name resolution
iHostResolver.GetByName(KNullDesC(),lNameEntry,lStatus);
User::WaitForRequest( lStatus );

if (lStatus == KErrNone)
{
lNameRecord = lNameEntry();
TInetAddr &lInetAddr = TInetAddr::Cast(lNameRecord.iAddr);
(TInetAddr::Cast(lNameRecord.iAddr)).Output(lHostName);
aHostName.Copy(lHostName);
iHostResolver.Close();
}
else
{
iHostResolver.Close();
lResult = KErrHostResolutionFailed;
}

}
else
{
lResult = KErrHostResolutionFailed;
}
}
return lResult;
}