开发者

Number of Transactions

I am in a need of multiple Transaction. But Bada is allowing me to do only one transaction. How to increase the number of Transaction? The code which i am using is

result HttpClient::TestHttpGet(Osp::Base::String link1)

{
int r1;
result r = E_SUCCESS;
HttpTransaction* pTransaction = null;
HttpRequest* pRequest = null;
String hostAddr(link1);

 if(__pSessi开发者_高级运维on == null)
 {
__pSession = new HttpSession();

r = __pSession->Construct(NET_HTTP_SESSION_MODE_NORMAL, null, hostAddr, null);

if (IsFailed(r))

 goto CATCH;

}


pTransaction = __pSession->OpenTransactionN();
r1=__pSession->GetActiveTransactionCount();
AppLog("Total no of transaction:%d",r);
if (null == pTransaction)
{
 r = GetLastResult();
 goto CATCH;
 }

r = pTransaction->AddHttpTransactionListener(*this);

if (IsFailed(r))

 goto CATCH;


 pRequest = const_cast<HttpRequest*>(pTransaction->GetRequest());

if(pRequest == null)
{
r = GetLastResult();

 goto CATCH;

}

r = pRequest->SetUri(link1);

if(IsFailed(r))

goto CATCH;

r = pRequest->SetMethod(NET_HTTP_METHOD_GET);

if(IsFailed(r))

 goto CATCH;

r = pTransaction->Submit();

if(IsFailed(r))

 goto CATCH;

return r;

CATCH:

 return r;
 }


You can have up to six simultaneous Session (HttpSession). Each session can start several transactions (HttpTransaction) but only sequentially.

My advice: use several sessions if you need to connect to different hosts. But for each host, use only one transaction at a time. You won't go faster if you try to make several connection to the same host (remember you are on a phone with limited network bandwith which has to be shared between parallel connections).


you can also try NET_HTTP_SESSION_MODE_PIPELINE to pipeline transactions within a session.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜