本文整理汇总了C++中DString::right方法的典型用法代码示例。如果您正苦于以下问题:C++ DString::right方法的具体用法?C++ DString::right怎么用?C++ DString::right使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DString
的用法示例。
在下文中一共展示了DString::right方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readMessage
int DServerSock::readMessage ( int hSock, DString &message )
{
int numberChar;
int availableNbChar = 0;
char * bufchar;
DString buffer;
bool finished = false;
// clear line
message.clear();
if ( hSock < 0 || m_status == NO_SOCKET )
{
m_status = NO_SOCKET;
m_lastError = "No opened socket found";
return m_status;
}
bufchar = new char[ m_buffSize + 1 ];
while ( ! finished )
{
ioctl( hSock, FIONREAD, &availableNbChar );
if ( availableNbChar )
{
memset ( bufchar, 0x0, m_buffSize + 1 );
numberChar = recv ( hSock, bufchar, sizeof( bufchar ), 0 );
if ( numberChar < 0 )
{
if ( ! message.length() )
{
m_lastError = "No data, ";
m_lastError += strerror ( errno );
m_status = RECV_NOTHING;
//break;
}
}
else if ( numberChar == 0 )
{
m_lastError = "Socket disconnected, ";
m_lastError += strerror ( errno );
m_status = NO_SOCKET;
break;
}
else
{
buffer = bufchar;
buffer.truncate ( numberChar );
if ( buffer.length() > 0 )
{
if (m_debug)
{
printMessage(buffer);
}
if ( buffer.right(2) == "\r\n" )
{
finished = true;
}
message += buffer;
m_status = SUCCESS;
m_lastError = "";
}
else
{
if ( ! message.length() )
{
m_status = RECV_EMPTY;
m_lastError = "Receive an empty message";
}
break;
}
}
}
else
{
finished = true;
}
}
delete[]( bufchar );
return m_status;
}