GPRS connection turn-off method in Symbian

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.