本文整理汇总了C++中CIOBuffer::SeekRead方法的典型用法代码示例。如果您正苦于以下问题:C++ CIOBuffer::SeekRead方法的具体用法?C++ CIOBuffer::SeekRead怎么用?C++ CIOBuffer::SeekRead使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIOBuffer
的用法示例。
在下文中一共展示了CIOBuffer::SeekRead方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_inter_send
void CTcpSocket::on_inter_send(short flag)
{
if (m_status == status_connect)
{
if ((flag&EV_WRITE) == EV_WRITE)
{
m_status = status_common;
switch (m_type)
{
case type_accepter:
if (m_acb)
{
m_acb->On_Connect(GetSocketID(), tcp_ok);
}
break;
case type_connecter:
if (m_ccb)
{
m_ccb->On_Connect(GetSocketID(), tcp_ok);
}
break;
default:
break;
}
}
else
{
XH_LOG_ERROR(logname_base, "[id:" << m_id << "] tcpsocket connect timeout");
on_inter_close(tcp_connectfail_timeout, true);
return;
}
}
else
{
while (!m_wait_send.empty())
{
CIOBuffer* buff = m_wait_send.front();
if ( buff->AvailRead()==0 )
{
XH_LOG_ERROR(logname_base, "[id:" << m_id << "] tcpsocket::send close cmd");
on_inter_close(tcp_close_byreset, false);
return;
}
bool bneedbreak = false;
int sendlen = ::send(m_socket, buff->GetCurRead(), buff->AvailRead(), 0);
if ( sendlen>0 )
{
buff->SeekRead(sendlen);
}
else if (sendlen<0)
{
if (isnoblockerr())
{
bneedbreak = true;
}
else
{
XH_LOG_ERROR(logname_base, "[id:" << m_id << "] tcpsocket::send failed send - 1");
on_inter_close(tcp_sendfail_senderr, false);
return;
}
}
else
{
bneedbreak = true;
}
//已经写完了,则回调通知
if (buff->AvailRead()==0)
{
switch (m_type)
{
case type_accepter:
if (m_acb)
{
m_acb->On_Send(GetSocketID(), tcp_ok, buff);
}
break;
case type_connecter:
if (m_ccb)
{
m_ccb->On_Send(GetSocketID(), tcp_ok, buff);
}
break;
default:
break;
}
m_wait_send.pop();
buff->Release();
}
if (bneedbreak) break;
}
}
//.........这里部分代码省略.........