Hi All,
I am new to Symbian and working on 9.1 and Series 60 SDK. I am creating a sample TCP client server application using Active object for emulator.
The procedure for client server communication is as following
1) TCP server socket is created.
2) Once created it listen to incoming connect request.
3) TCP client socket is created and try to connect to TCP server socket.
4) TCP server creates a service socket and accept the connection request.
5) TCP client sends packet on connected socket to TCP server
6) Here TCP server socker does not get any packets. Its RunL function is never called.
The code is shown below
TCP CLIENT:
_________________________________________________________________
Socket creation and connecting code
{
//Destination port
const TInt KEchoPort = 1234;
//Destination ip address
const TUint32 KInetAddr = INET_ADDR(127,0,0,1);
//Destination addres as InetAddr format
TInetAddr destAddr;
//Connect Server Socket
if( KErrNone != ssCli.Connect())
{
CEikonEnv::Static()->AlertWin(_L("Fail to Connect SerSocket"));
}
//Open client socket
if( KErrNone != sockCli.Open(ssCli, KAfInet, KSockStream, KProtocolInetTcp))
{
CEikonEnv::Static()->AlertWin(_L("Fail to Open Client Socket"));
}
//Set destination address
destAddr.SetFamily(KAfInet);
destAddr.SetAddress(KInetAddr);
destAddr.SetPort(KEchoPort);
//Send packet but do not wait to let the task complete
sockCli.Connect(destAddr,iStatus);
//Changing the state of socket to Connecting
iState = Connecting;
SetActive();
}
RunL for client is called on successful connection to server
Packet sending code:
{
TBuf8<256> iWrite(_L8("abcdefghijklmnopqrstuvwxyz"));
//Send packet but do not wait to let the task complete
sockCli.Send(iWrite,NULL,iStatus);
//Changing the state of socket to Sending
iState = Sending;
SetActive();
}
RunL for client is called on successful packet sending.
_________________________________________________________________
TCP SERVER:
_________________________________________________________________
Socket creation and listening code
{
//Error number buffer
TBuf<32> errNo;
//Error code
TInt errCode;
//Destination port
const TInt KEchoPort = 1234;
//Destination ip address
const TUint32 KInetAddr = INET_ADDR(127,0,0,1);
//Destination addres as InetAddr format
TInetAddr anAddr;
//Connect Server Socket
if( KErrNone != ssSer.Connect())
{
CEikonEnv::Static()->AlertWin(_L("Fail to Connect SerSocket"));
}
//Open client socket
if( KErrNone != sockSer.Open(ssSer, KAfInet, KSockStream, KProtocolInetTcp))
{
CEikonEnv::Static()->AlertWin(_L("Fail to Open Client Socket"));
}
//Set source address to which client will bind
anAddr.SetFamily(KAfInet);
anAddr.SetAddress(KInetAddr);
anAddr.SetPort(KEchoPort);
CEikonEnv::Static()->AlertWin(_L("Binding"));
//Bind socket to source address
errCode = sockSer.Bind(anAddr);
errNo.Num(errCode);
CEikonEnv::Static()->AlertWin(errNo);
if( KErrNone != errCode )
{
CEikonEnv::Static()->AlertWin(_L("Fail to Bind Socket"));
}
CEikonEnv::Static()->AlertWin(_L("Listening"));
//Listen socket for incoming request
User::LeaveIfError(sockSer.Listen(1));
CEikonEnv::Static()->AlertWin(_L("Accepting"));
//Aceepting request and creating a new service socket
sockBlank.Open(ssSer);
sockSer.Accept(sockBlank,iStatus);
//Change the socket status to Accepting
iState = Accepting;
SetActive();
}
RunL for server is called on successful accepting of client request
Packet receiving code:
{
sockBlank.Recv(iRecv,NULL,iStatus);
//Change the socket status to Receiving
iState = Receiving;
SetActive();
}
This code is executed successfully. But no call back is received in RunL of server active object
_________________________________________________________________
Does anybody has observed such behavior? Please provide guidence to trace the issue.
Thanks & Regards
Rajat


maybe you will be saved as well. so watch it out 

