Hi there,
I've made a program which sends every 6sec 100 character long data to server. Also if send fails, I put the data in db and at later try to send again.
Now I've faced a small issue. In first try, I get KErrNoMemory when program was running a while.
But when I changed on thing error was gone(see the bold code), or so it looks like..
Also I have to write one data at time to server, so if someone knows much better solution please advise
Sending current data:
Sending old data,only the callback function is different:Code:void CSocketSender::SendL(TInetAddr aAddrs,const TDesC8& aRequest) { iRequest = aRequest; TInt ret = iSocket.Open(iSocketServer, KAfInet, KSockStream, KProtocolInetTcp); if(ret == KErrNone) { iState = EConnecting; iSocket.Connect(aAddrs,iStatus); SetActive(); } else { iNotifier.SendCompletedL(ret,iRequest); } }
And RunL:Code:void CSocketSender::SendBuffer(TInetAddr aAddrs,const TDesC8& aRequest) { iRequest = aRequest; TInt ret = iSocket.Open(iSocketServer, KAfInet, KSockStream, KProtocolInetTcp); if(ret == KErrNone) { iState = EConnectingbuffer; iSocket.Connect(aAddrs,iStatus); SetActive(); } else { iNotifier.BufferSendCompletedL(ret); } }
And DoCancel()Code:void CSocketSender::RunL() { switch(iState) { case EConnecting: { iState = ESendingCurrent; iSocket.Write(iRequest,iStatus); SetActive(); break; } case EConnectingbuffer: { iState = ESendingBuffer; iSocket.Write(iRequest,iStatus); SetActive(); break; } case ESendingCurrent: { Cancel(); iState = ESendingBuffer; iNotifier.SendCompletedL(iStatus.Int(),iRequest); break; } case ESendingBuffer: { //before //Cancel() //After iSocket.CancelAll(); iSocket.Close(); iNotifier.BufferSendCompletedL(iStatus.Int()); break; } default: break; } }
Edit: It didn't remove errorCode:void CSocketSender::DoCancel() { iSocket.CancelAll(); iSocket.Close(); }![]()





