📄 readerudp.cpp
字号:
#include "readerudp.h"
#include "socketsenginenotifier.h"
CReaderUdp* CReaderUdp::NewL(MSocketsEngineNotifier& aEngineNotifier, RSocket& aSocket)
{
CReaderUdp* self = new (ELeave) CReaderUdp(aEngineNotifier, aSocket);
CleanupStack::PushL(self);
self->ConstructL();
CleanupStack::Pop(self);
return self;
}
CReaderUdp::CReaderUdp(MSocketsEngineNotifier& aEngineNotifier, RSocket& aSocket)
: CActive(EPriorityStandard),
iSocket(aSocket),
iEngineNotifier(aEngineNotifier)
{
}
CReaderUdp::~CReaderUdp()
{
Cancel();
}
void CReaderUdp::DoCancel()
{
if(iSocket.SubSessionHandle())
iSocket.CancelRead();
}
void CReaderUdp::ConstructL()
{
CActiveScheduler::Add(this);
}
void CReaderUdp::RunL()
{
switch (iStatus.Int())
{
case KErrNone:
iEngineNotifier.ResponseReceived(iBuffer, iRecvFrom);
IssueRead();
break;
case KErrDisconnected:
iEngineNotifier.ReportError(MSocketsEngineNotifier::EDisconnected,
iStatus.Int());
break;
default:
iEngineNotifier.ReportError(MSocketsEngineNotifier::EGeneralReadError,
iStatus.Int());
break;
}
}
void CReaderUdp::IssueRead()
{
if(iSocket.SubSessionHandle())
{
iRecvFrom.SetAddress(KInetAddrAny);
iRecvFrom.SetPort(0);
iBuffer.Zero();
iBuffer.SetLength(0);
iSocket.RecvFrom(iBuffer, iRecvFrom, 0, iStatus, iXfrLen);
if(!IsActive())
SetActive();
}
}
void CReaderUdp::Start()
{
if (!IsActive())
{
IssueRead();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -