In Symbian development, many friends have raised the GPRS connection can not turn off the problem.
The main symptom of this problem is that when we turn off the GPRS connection, the program exits abnormally. Proven
What is this for?
I have done a lot of experiments, all the same effect, even with the example provided by the Nokia forum is the same result.
As long as the socket engine a delete, the entire program will quit.
Take Httpexample For example, let's look at how its destructor operates:
CClientEngine::~CClientEngine() {
iSession.Close();
iSocketServ.Close() ;
delete iPostData;
iPostData = NULL;
}
I've tried this destructor, and if you delete the Cclientengine engine object directly, the program will not hesitate to
Quit, not turn off the connection. If you drop the isocketserv.close () note, just like the following:
CClientEngine::~CClientEngine() {
iSession.Close();
// iSocketServ.Close() ; <------ 注释掉
delete iPostData;
iPostData = NULL;
}
Then the program's GPRS connection will not be disconnected at all.
What can be done about it? We know that the Symbian system is also running on the ARM processor, and the ISession is a file operation on the Flash chip. So will it be because the chip processing speed is too slow or because the turn-off ISession takes a while (in fact, 1-2 seconds), and this operation is precisely the result of asynchronous behavior?
Let's assume that if the operation of Isession.close () is asynchronous, we call Isockserv.close () before the Symbian system has isession closed, which leads to an error.
In the first question, I started the experiment by manually adding the following function:
void CClientEngine::CloseSockSvr()
{
iSocketServ.Close() ;
if(iCurConn == EConnected) iCurConn = ENotConnected ;
}
void CClientEngine::CloseSession()
{
iSession.Close() ;
}
That is, instead of directly closing the ISession and Isocketserv from the destructor, the two closed functions are separated into public functions, which are closed by the outside of the Cclientengine engine.
Test proved that this way from the menu, the first hand off ISession, and then a China, and then manually shut down the Isocketserv, is fully able to achieve the GPRS connection closed, and the program will not quit.