Symbian(RSocket DownLoad)模拟HTTP下载
2010-10-20 07:59:57 来源:WEB开发网SetActive();
}
//好,请求部分完了之后,让我们来看看如何响应了.哈哈!!!!
void CWebClientEngine::RunL()
{
if (iStatus.Int() == KErrNone)
{
switch (iState)
{
case EResolving:
{
//域名解析完成后
//连接HOST
User::LeaveIfError(iSocket.Open(iSockServer, KAfInet,
KSockStream,
KProtocolInetTcp, iConnection));
TInetAddr address;
address = iHostAddress().iAddr;
address.SetPort(port);
iState = EConnecting;
iSocket.Connect(address, iStatus) ;
SetActive();
}
break;
case EConnecting:
{
//连接成功后,发送请求
iSocket.Write(iRequest->Des(), iStatus) ;
iState = ESending;
SetActive();
}
break;
case ESending:
{
//请求成功后,准备接收数据
iResponseChunk.Zero() ;
iSocket.RecvOneOrMore(iResponseChunk, 0, iStatus,
iResponseChunkSizePkg) ;
iState = EReceiving;
SetActive();
}
break;
case EReceiving:
{
//接收数据
int errCode = 0;
if (CheckRecv(iResponseChunk))//判断是否为移动拦截页
{
//解析数据
if (ParseWebFileInfo(iResponseChunk, SizeL, HrdLen,
errCode))
{
if (HandleStatus(errCode))
{
return;
}
//写文件
// SizeL += iDownloadSize;
iDownloadSize+=iResponseChunk.Length()-
HrdLen;
iObserver->HandleHttpProgress(SizeL,
iDownloadSize);
iObserver->HandleWebData(iResponseChunk.Mid
(HrdLen));
}
else
{
//写文件
更多精彩
赞助商链接