Following is my code to test socket on Symbian OS, I send a package which length is 6 and data are all 0, the server will back a package, but why I can't receive the package? Thanks a lot!!
Code:void CTcpEngine::RunL() { switch(iChannelState) { case EChannelConnected: { if (iStatus==KErrNone) { // Connection was made successfully iStatusText=_L("\nConnection established"); NotifyProgress(); TText8 pack[6] = {0, 0, 0, 0, 0, 0}; iWriteDataBuffer.Append(pack, 6); iChannelState=EChannelSending; iSocket.Send(iWriteDataBuffer, 0, iStatus); SetActive(); } else { iStatusText=_L("\nFailed to connect"); NotifyProgress(); } } break; case EChannelSending: { // Receive data from the "server" iStatusText=_L("\nSent data"); NotifyProgress(); iSocket.RecvOneOrMore(iReadDataBuffer, 0, iStatus, iRecvLen); iChannelState=EChannelReceiving; SetActive(); } break; case EChannelReceiving: { if (iStatus == KErrNone) { // Data was received successfully iStatusText=_L("\nReceived data"); NotifyProgress(); // Display received data in user interface //iStatusText=iReadDataBuffer; //NotifyProgress(); } else { iStatusText=_L("\nError reading data"); NotifyProgress(); } iStatusText=_L("\nClose the connection..."); NotifyProgress(); iSocket.Close(); iStatusText=_L("\nEnd of test."); NotifyProgress(); } break; default: break; } }




