本文整理汇总了C++中ACE_Message_Block::reset方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_Message_Block::reset方法的具体用法?C++ ACE_Message_Block::reset怎么用?C++ ACE_Message_Block::reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_Message_Block
的用法示例。
在下文中一共展示了ACE_Message_Block::reset方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
int
PSession::initiate_write (u_long offset_low, u_long offset_high,
const char * data,
size_t len)
{
ACE_Message_Block *mb = 0;
u_int blksize = this->config().s_blksize();
if (blksize < len)
{
blksize=len;
}
ACE_NEW_RETURN (mb,
ACE_Message_Block (blksize),
-1);
if (mb == 0)
{
this->do_cancel ();
return -1;
}
mb->reset ();
mb->copy (data, len);
//mb->wr_ptr (mb->space());
return this->initiate_write (offset_low, offset_high, *mb);
}
示例2:
/*****************************************************************************
Function: sendEsRtpPacket
Description:
Input: pRtpData 解析成ES流后的一包数据
unDataSize ES流的一包数据的长度
Output:
Return: N/A
*****************************************************************************/
void CPs2EsProcessor::sendEsRtpPacket(const char* pRtpData, unsigned int unDataSize)
{
//CHECK_POINTER_VOID(pRtpData);
if (0 == unDataSize)
{
//BP_RUN_LOG_ERR(IVS_FAIL, "Send Es rtp packet fail, data size invalid", "size=%u, serviceID=%s.", unDataSize, m_strServiceID.c_str());
return;
}
ACE_Message_Block *pRtpBlock = CMediaBlockBuffer::instance().allocMediaBlock();
if (NULL == pRtpBlock)
{
//BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Alloc media block fail.", "serviceID=%s.", m_strServiceID.c_str());
return;
}
NALU_HEADER naluheader = *(NALU_HEADER*)pRtpBlock->rd_ptr();
pRtpBlock->reset();
pRtpBlock->copy(pRtpData, unDataSize);
ST_FRAME_DATA frameData;
frameData.iFrameDataType = naluheader.TYPE;
frameData.iStreamType = _PAY_LOAD_TYPE_H264;
//m_Mutex.Lock();
if(NULL != m_fDataCallBack)
{
m_fDataCallBack(m_pUser, pRtpBlock,&frameData);
}
//m_Mutex.UnLock();
CMediaBlockBuffer::instance().freeMediaBlock(pRtpBlock);
return;
}
示例3: on_read_finished
virtual int on_read_finished (ACE_Message_Block & mb,
int error,
int xfer_bytes)
{
if (error !=0 || xfer_bytes == 0)
{
return -1;
}
mb.reset ();
mb.copy (data );
mb.reset ();
mb.wr_ptr (cfg.blksize());
return this->start_write (mb);
}
示例4: on_write_finished
virtual int on_write_finished (ACE_Message_Block & mb,
int error)
{
if (error !=0)
{
return -1;
}
mb.reset ();
return this->start_read (mb);
}
示例5: on_open
virtual int on_open ()
{
ACE_Message_Block * mb = this->alloc_msg ();
if (mb == 0 )
{
return 0;
}
mb->copy (data );
mb->reset ();
mb->wr_ptr (cfg.s_blksize ());
return this->start_write (*mb);
}
示例6:
void
HTTP_Client_Connection::on_write_some(ACE_Message_Block& mb, size_t bytes_transferred)
{
// keep writing
if ( mb.length() > 0 )
{
this->write(mb);
return;
}
// write completed
else
{
buf_.resize(0);
mb.reset();
this->read(mb);
}
}
示例7:
ACE_Message_Block *
PConnection::alloc_msg ()
{
ACE_Time_Value tv = ACE_Time_Value::zero;
ACE_Message_Block * mb = 0;
if (free_mq_.dequeue_head (mb, &tv) >= 0)
{
mb->reset ();
return mb;
}
if (ACE_OS::last_error () != EWOULDBLOCK)
return mb;
u_int blksize = this->config().r_blksize();
ACE_NEW_NORETURN (mb, ACE_Message_Block (blksize));
return mb;
}
示例8: buffer
//.........这里部分代码省略.........
break;
p++;
}
if (p == buffer.wr_ptr ())
continue;
end_of_current_line = p;
}
else
{
if (buffer.wr_ptr ()[-1] != '\n')
{
buffer.wr_ptr ()[0] = '\n';
buffer.wr_ptr (1);
}
last_line_was_read = 1;
}
buffer.wr_ptr ()[0] = '\0';
}
if (end_of_current_line == 0)
{
end_of_current_line = buffer.rd_ptr ();
while (*end_of_current_line != '\n')
end_of_current_line++;
}
// If buffer is not pointing to a continuation line, or there is
// no more input, then can commit the scanned configuration
// line.
if (line.length () != 0
&& ((last_line_was_read && buffer.length () == 0)
|| (buffer.rd_ptr ()[0] != ' '
&& buffer.rd_ptr ()[0] != '\t')))
{
ACE_TCHAR *name = 0;
ACE_TCHAR *value = 0;
name = line.rd_ptr ();
for (p = name; *p != '\0'; p++)
{
if (*p == '=')
{
line.rd_ptr (p+1);
while (p != name && (p[-1] == ' ' || p[-1] == '\t'))
p--;
*p = '\0';
}
}
if (*name)
{
value = line.rd_ptr ();
while (*value == ' ' || *value == '\t')
value++;
p = line.wr_ptr ();
while (p != value && (p[-1] == ' ' || p[-1] == '\t'))
p--;
*p = '\0';
sym_name = this->strings_->duplicate (name);
sym_value = this->strings_->duplicate (value);
this->symbols_->rebind (sym_name, sym_value);
}
line.reset ();
}
// If we are done, we are done!
if (last_line_was_read && buffer.length () == 0)
break;
// If the buffer is pointing at a comment line, ignore it.
if (buffer.rd_ptr ()[0] == '#'
|| buffer.rd_ptr ()[0] == '\n'
|| (buffer.rd_ptr ()[0] == '\r' && buffer.rd_ptr ()[1] == '\n'))
{
buffer.rd_ptr (end_of_current_line + 1);
buffer.crunch ();
continue;
}
// Whatever is left is either the start of a name-value-pair or a
// continuation of one.
line.copy (buffer.rd_ptr (),
end_of_current_line - buffer.rd_ptr ());
p = line.wr_ptr ();
while (p != line.rd_ptr () && (p[-1] == ' ' || p[-1] == '\t'))
p--;
line.wr_ptr (p);
line.wr_ptr ()[0] = '\0';
buffer.rd_ptr (end_of_current_line + 1);
buffer.crunch ();
}
fio.close ();
}
示例9: svc
int HDCCUSvrHandler::svc()
{
#define MES_DATA_HEAD_LEN 2
ACE_DEBUG((LM_DEBUG,"ACE 打开连接............"));
ACE_Message_Block * mb = NULL;
ACE_Time_Value tv(5);
if (this->getq(mb,&tv) == -1) return -1;
HD8583STRUCT req;
HD8583STRUCT resp;
MESSAGETYPE msg_type;
char * buffer = mb->rd_ptr();
int len = 0;
// 数据段长度超过允许范围,忽略请求
if(UnPackResponseStruct(req,&msg_type,buffer,mb->length()) != 0)
{
ACE_ERROR((LM_ERROR,"数据包不合法"));
mb->release();
return -1;
}
ACE_HEX_DUMP((LM_DEBUG,mb->rd_ptr(),mb->length()));
try
{
HDResponseHandler* handler = HDCCUProcessUnits::Instance().Create(msg_type);
if(handler)
{
resp.Init();
int result = handler->DoResponse(req,resp,peer().get_handle());
if(result > 0)
{
// send back
mb->reset();
buffer = mb->wr_ptr();
len = (int)PackRequestStruct(resp,msg_type,buffer,mb->size());
mb->wr_ptr(len);
ACE_HEX_DUMP((LM_DEBUG,buffer,mb->length()));
ACE_DEBUG((LM_DEBUG,"数据包长度[%d]",mb->length()));
if(peer().send_n(mb->rd_ptr(),mb->length()) <=0 )
{
ACE_DEBUG((LM_ERROR,"发送应答包失败"));
}
}
else if(result == 0)
{
// OK
ACE_DEBUG((LM_DEBUG,"处理成功"));
}
else
{
// error
ACE_DEBUG((LM_ERROR,"处理请求失败,返回码[%d]",result));
}
}
else
{
ACE_ERROR((LM_ERROR,"不能处理请求代码[%c]",msg_type));
}
}
catch(...)
{
// 捕获所有的异常
ACE_ERROR((LM_ERROR,"处理请求异常,请求代码[%02x]",msg_type));
}
mb->release();
return 0;
}