hi, i am trying to make a connection from my emulotor to a server that on the same pc as my emulator. the server is in java. i have looked through the example provided by symbian but don't really know how they make the connection. i just want to make a connection to the server currently, no writing or reading yet. i tried a bit of codng myself but it dosn't seem to be able to connect. below is a fragment of my code.

////////////////////////davidSocketAppUi.cpp////////////////////////
void CDavidSocketAppUi::ConstructL()
{
BaseConstructL();

iAppView = new (ELeave) CDavidSocketView(this);
CleanupStack::PushL(iAppView);
iAppView->ConstructL();
CleanupStack::Pop();
AddViewL(iAppView);

iSocketsEngine = CDavidSocketSocket::NewL(this);
iSocketsEngine->GetPage();

SetDefaultViewL(*iAppView);
}

// ----------------------------------------------------
// CDavidSocketAppUi::~CDavidSocketAppUi()
// Destructor
// Frees reserved resources
// ----------------------------------------------------
//
CDavidSocketAppUi::~CDavidSocketAppUi()
{
delete iSocketsEngine;
}

////////////////////////socket.cpp////////////////////////
_LIT(KDefaultServerName, "127.0.0.1"
static const TInt KPortNumber = 7000;

CDavidSocketSocket* CDavidSocketSocket::NewL(CDavidSocketAppUi* aAppUi)
{
CDavidSocketSocket* self = CDavidSocketSocket::NewLC(aAppUi);
CleanupStack::Pop();
return self;
}


CDavidSocketSocket* CDavidSocketSocket::NewLC(CDavidSocketAppUi* aAppUi)
{
CDavidSocketSocket* self = new (ELeave) CDavidSocketSocket(aAppUi);
CleanupStack::PushL(self);
self->Init();
return self;
}


CDavidSocketSocket::CDavidSocketSocket(CDavidSocketAppUi* aAppUi)
: CActive(EPriorityStandard),
iServerName(KDefaultServerName),
iAppUi(aAppUi)
{
}

CDavidSocketSocket::~CDavidSocketSocket()
{
Cancel();
iSocket.Close();
iSocketServ.Close();

}

void CDavidSocketSocket::Init()
{
iDataOK = EFalse;

iSocketStatus=ENotConnected;

CActiveScheduler::Add(this);
iIsAllreadyImage=EUnknown;

User::LeaveIfError(iSocketServ.Connect());
}

void CDavidSocketSocket::iConnect2(TUint32 aAddr)
{
if (iSocketStatus == ENotConnected)
{
iSocket.Close();
User::LeaveIfError(iSocket.Open(iSocketServ, KAfInet, KSockStream, KProtocolInetTcp));

iAddress.SetPort(KPortNumber);
iAddress.SetAddress(aAddr);

if (iStatus == KErrNone)
{
iAppUi->AlertWin(_L("istatus is kerrnone&quot);
}
iSocket.Connect(iAddress, iStatus);

if (iStatus == KErrNone)
{
iAppUi->AlertWin(_L("istatus is kerrnone&quot);
}

iSocketStatus=EConnecting;

SetActive();

}
else
{
iAppUi->AlertWin(_L("Can't connect!&quot);
}
}


// Initiate connection process
void CDavidSocketSocket::iConnect()
{
if (iSocketStatus == ENotConnected)
{
TInetAddr addr;
if (addr.Input(iServerName) == KErrNone) // server name is already a valid ip address
{
iConnect2(addr.Address());
}
else
{
User::LeaveIfError(iResolver.Open(iSocketServ, KAfInet, KProtocolInetUdp));
iSocketStatus=ELookingUp;
iResolver.GetByName(iServerName, iNameEntry, iStatus);
SetActive();
}
}
}

void CDavidSocketSocket::iDisconnect()
{
Cancel(); // cancel current operation
iSocketStatus=ENotConnected;
iSocket.Close();
}

void CDavidSocketSocket::GetPage()
{
if(iSocketStatus!=ENotConnected) return;

Cancel();
iDummyLength=0;
iReadbuffer.Zero();
iWriteBuffer.Zero();
iConnect();
}

void CDavidSocketSocket:oCancel()
{
switch (iSocketStatus)
{
case ESending:
iSocket.CancelWrite();
break;

case EReceiving:
iSocket.CancelRead();
break;

case EConnecting:
iSocket.CancelConnect();
break;

case ELookingUp:
iResolver.Cancel();
iResolver.Close();
break;

case EConnected:
Cancel();
break;

case EDisconnecting:
break;

default:
break;
}

iSocket.Close();
iSocketStatus=ENotConnected;
}

void CDavidSocketSocket::RunL()
{

switch(iSocketStatus)
{
case ELookingUp: // Looking for DNS -> IP name

iResolver.Close();
if (iStatus == KErrNone) // DNS look up successful.
{
iNameRecord = iNameEntry(); // Proceed with actual connecting
TBuf<15> ipAddr;
TInetAddr::Cast(iNameRecord.iAddr).Output(ipAddr);
iSocketStatus=ENotConnected;
iConnect2(TInetAddr::Cast(iNameRecord.iAddr).Address());
}
else // DNS lookup failed
{
iAppUi->AlertWin(_L("DNS Lookup failed!&quot);
iSocketStatus=ELookUpFailed;
iDisconnect();
}
break;

case EConnecting:
if (iStatus == KErrNone) // Connection completed successfully
{
iSocketStatus=EConnected; // Continue with write-operation and
iWrite();
}
else
{
iSocketStatus=EConnectFailed;
iAppUi->AlertWin(_L("Connection failed!&quot);
iDisconnect();
}
break;

case ESending: // Page-request has been sent.
if (iStatus == KErrNone)
{
iSocketStatus=EReceiving;
iRead();
}
else
{
iAppUi->AlertWin(_L("Request send failed!&quot);
iDisconnect();
}
break;

case EReceiving: // Should be called when read is complete
if (iStatus == KErrNone) // and server has closed connection
{
iRead();
}
else if (iStatus == KErrEof) // All done and conn closed
{
iDisconnect();
}
else
{
iAppUi->AlertWin(_L("Receive error!&quot);
iDisconnect();
}
break;

case EDisconnecting:
if (iStatus == KErrNone) // Disconnected successfully
{
iSocket.Close();
iSocketStatus=ENotConnected;
}
else
{
iSocketStatus=EConnectFailed;
iAppUi->AlertWin(_L("Connection failed!&quot);
}
iSocketStatus=ENotConnected;
break;

default:
break;
};
}