本文整理汇总了C++中Header::GetHeader方法的典型用法代码示例。如果您正苦于以下问题:C++ Header::GetHeader方法的具体用法?C++ Header::GetHeader怎么用?C++ Header::GetHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Header
的用法示例。
在下文中一共展示了Header::GetHeader方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Send
BOOL KUVSocket::Send(H_CONNECTION handle, LPSTR pData, UINT nDataLen)
{
BOOL bRet = false;
g_ClearError();
// check
if (handle < 1 || handle > m_nIdGen)
{
sprintf_s(g_ErrorMsg, "KUVSocket::Send Fail, the handle is Error : %d\n%s", handle,g_ErrorMsg);
return bRet;
}
if (!pData)
{
sprintf_s(g_ErrorMsg, "KUVSocket::Send Fail, the send data is emtpy\n%s", g_ErrorMsg);
return bRet;
}
uv_tcp_t* pTcp = getUVHandle(handle);
if (!pTcp)
{
sprintf_s(g_ErrorMsg, "KUVSocket::Send Fail, can't get uv_tcp_t with handle : %d\n%s", handle, g_ErrorMsg);
return bRet;
}
if (!uv_is_writable((uv_stream_t*)pTcp))
{
sprintf_s(g_ErrorMsg, "KUVSocket::Send Fail,this pTcp is unable for writing: %d\n%s", handle, g_ErrorMsg);
return bRet;
}
Header *pHeader = new Header();
pHeader->SetDataLen(nDataLen);
SendReq* pSendReq = new SendReq();
pSendReq->pHeader = pHeader;
uv_buf_t buff[2];
buff[0] = uv_buf_init((LPSTR)pHeader->GetHeader(), pHeader->GetHeaderSize());
buff[1] = uv_buf_init(pData, nDataLen);
m_nError = uv_write(pSendReq, (uv_stream_t*)pTcp, buff, 2, OnConnectionWriteCompleted);
if (m_nError != 0)
{
delete pHeader;
delete pSendReq;
sprintf_s(g_ErrorMsg, "KUVSocket::Send Fail, uv_write get UV Error Code: %d\n%s", m_nError, g_ErrorMsg);
return bRet;
}
bRet = TRUE;
return bRet;
}