本文整理汇总了C++中PSockEvent::OnWrite方法的典型用法代码示例。如果您正苦于以下问题:C++ PSockEvent::OnWrite方法的具体用法?C++ PSockEvent::OnWrite怎么用?C++ PSockEvent::OnWrite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PSockEvent
的用法示例。
在下文中一共展示了PSockEvent::OnWrite方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnWrite
void TSockSys::OnWrite(uv_write_t *WriteHnd, int Status) {
// cast to our write request object to get access to buffer
uv_write_req_t* _WriteHnd = (uv_write_req_t*)WriteHnd;
// get socket handle
uv_tcp_t* SockHnd = (uv_tcp_t*)WriteHnd->handle;
IAssert(SockSys.IsSockHnd((uint64)SockHnd));
// free buffer and write handle
free(_WriteHnd->Buffer.base);
free(_WriteHnd);
// get socket id
const uint64 SockId = SockSys.SockHndToIdH.GetDat((uint64)SockHnd);
IAssert(SockSys.IsSock(SockId));
// get socket event
const uint64 SockEventId = SockSys.SockHndToEventIdH.GetDat((uint64)SockHnd);
PSockEvent SockEvent;
if (SockSys.IsSockEvent(SockEventId)) {
SockEvent = SockSys.GetSockEvent(SockEventId);
} else {
SaveToErrLog("SockSys.OnWrite: Socket without SockEvent");
return;
}
// execute callback
if (Status == 0) {
SockEvent->OnWrite(SockId);
} else {
TStr ErrMsg = (Status == -1) ?
"SockSys.OnWrite: " + SockSys.GetLastErr() :
"SockSys.OnWrite: Error writing to socket";
SockEvent->OnError(SockId, Status, ErrMsg);
}
}