Problem Ctimer
| Wed, 2007-12-05 17:16 | |
|
Hi, i have a problem with CTimer. void CgprsConnection::ConnectL()What is the problem? |
|
| Wed, 2007-12-05 17:16 | |
|
Hi, i have a problem with CTimer. void CgprsConnection::ConnectL()What is the problem? |
|
Forum posts: 2009
At least you should not create your RConnection object in a local variable. Same for the Host Resolver (btw, you do not seem to use it )
Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant
Forum posts: 116
Hi,
Keep the "SetActive()" method inside the "if" condition.
if ( iEngineStatus == ENotConnected )
{
.....
.....
.....
// Request time out
iTimer->After( KTimeOut );
SetActive();
}
Chao,
Raghav
Forum posts: 158
I try to use RTimer, and the first time work, but the second time phone reboot.
I use itimer->after(status, time) to start timer and itimer->cancel for delete timer pendent.
After cancel i must restart timer? I think that application chrash when recall itimer->after(status, time), but why?
Thanks
Silvia
Forum posts: 116
Hi Silvia,
Will you tell why are you calling "SetActive()" for cases where "iEngineStatus != ENotConnected".
Are you requesting other asynchronous service other than "CTimer", if this is the case then you need to have a seperate AOs for each asynch service requests.
Chao,
Raghav
Forum posts: 158
I return to use CTimer, now application go to timeExipred for two time, but the therd time jump to runL without give timeexpired, why?
Its a very very problem for me
My code:
void CgprsConnection::ConnectL() { // Initiate connection process if ( iEngineStatus == ENotConnected ) { isConnect=1; TInt code = 55; while((code = iSocketServ.Connect()) != KErrNone) { User::After(3000000); } RConnection conn; _LIT(KRasAddr,"ip"); destAddr.Input(KRasAddr); destAddr.SetPort(KDefaultPortNumber); // Connect to the socket server // Open an RConnection object. Note that you must provide the RSocketServ object conn.Open(iSocketServ); conn.GetIntSetting(KSetting, codice); // Start an Outgoing Connection with overrides conn.Start(prefs); // Open a Host Resolver associated with the connection RHostResolver hr; hr.Open(iSocketServ, KAfInet, KProtocolInetTcp, conn); // Open a Socket associated with the connection User::LeaveIfError(sock.Open(iSocketServ, KAfInet, KSockStream, KProtocolInetTcp, conn)); sock.Connect(destAddr, iStatus); ChangeStatus( EConnecting ); // Request time out iTimer->After( /*timerStatus,*/KTimeOut ); SetActive(); } } void CgprsConnection::TimerExpired() { Cancel(); Disconnect(); ChangeStatus( ENotConnected ); ConnectL(); } void CgprsConnection::Disconnect() { delete iTimer; iTimer = NULL; iTimer = CTimeOutTimer::NewL( EPriorityHigh, *this ); sock.CancelAll(); sock.CancelConnect(); sock.Close(); iSocketServ.Close(); ChangeStatus( ENotConnected ); isConnect=1; }Some idea?
Many thanks
Silvia
Forum posts: 116
Hi,
Its almost impossible to answer this without looking into the code of RunL().
You may get some response by posting the implementation of RunL() method.
Chao,
Raghav
Forum posts: 158
ok, sorry
void CgprsConnection::RunL() { iTimer->Cancel(); switch( iEngineStatus ) { case EConnecting: { if ( iStatus == KErrNone ) { ChangeStatus( EConnected ); isConnect =0; SendMessage(); } else { ChangeStatus( ENotConnected ); isConnect=1; Disconnect(); User::After(1000000); //3000000 delete iTimer; iTimer = NULL; iTimer = CTimeOutTimer::NewL( EPriorityHigh, *this ); ConnectL(); //riprovo a connettermi } break; } case EControl: { if ( iStatus == KErrNone ) { ChangeStatus(EConnected); isConnect=0; ReadMessage(); } else { ChangeStatus( ENotConnected ); isConnect=1; Disconnect(); User::After(1000000); //3000000 ConnectL(); //riprovo a connettermi } break; } case EClosed: { Disconnect(); break; } case ENotConnected: { isConnect=1; Disconnect(); User::After(1000000); //3000000 delete iTimer; iTimer = NULL; iTimer = CTimeOutTimer::NewL( EPriorityHigh, *this ); ConnectL(); //riprovo a connettermi break; } default: { } break; }; }Many Thanks
Silvia
Forum posts: 116
Hi,
Check for the state of "iEngineStatus" to make sure all possible states are handled properly in the switch statement.
Chao,
Raghav
Forum posts: 158
The strange event is that for 4 time application go to inside timeexpired (and is correct!!!) ,instead the 5 time application go inside runL, is very very strange
But is problem of socket or timer?