本文整理汇总了C++中TcpConnectionPtr::recv方法的典型用法代码示例。如果您正苦于以下问题:C++ TcpConnectionPtr::recv方法的具体用法?C++ TcpConnectionPtr::recv怎么用?C++ TcpConnectionPtr::recv使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TcpConnectionPtr
的用法示例。
在下文中一共展示了TcpConnectionPtr::recv方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onTcpSendComplete
//-----------------------------------------------------------------------------
// 描述: TCP连接上的一个发送任务已完成
//-----------------------------------------------------------------------------
void AppBusiness::onTcpSendComplete(const TcpConnectionPtr& connection, const Context& context)
{
logger().writeStr("onTcpSendComplete");
connection->recv(SELF_PACKET_SPLITTER, EMPTY_CONTEXT);
// connection->recv(SELF_PACKET_SPLITTER, EMPTY_CONTEXT, RECV_TIMEOUT);
//connection->recv(SELF_PACKET_SPLITTER, EMPTY_CONTEXT);
}
示例2: onTcpConnected
void AppBusiness::onTcpConnected(const TcpConnectionPtr& connection)
{
logger().writeFmt("onTcpConnected (%s) (ConnCount: %d)",
connection->getPeerAddr().getDisplayStr().c_str(),
connection->getServerConnCount());
connection->recv();
}
示例3: onTcpRecvComplete
void ServerModule_Chargen::onTcpRecvComplete(const TcpConnectionPtr& connection, void *packetBuffer,
int packetSize, const Context& context)
{
logger().writeFmt("[%s] Discarded %u bytes.",
connection->getConnectionName().c_str(), packetSize);
connection->recv();
}
示例4: onTcpRecvComplete
//-----------------------------------------------------------------------------
// 描述: TCP连接上的一个接收任务已完成
//-----------------------------------------------------------------------------
void AppBusiness::onTcpRecvComplete(const TcpConnectionPtr& connection, void *packetBuffer,
int packetSize, const Context& context)
{
logger().writeStr("onTcpRecvComplete");
char *dataptr=(char*)packetBuffer;
string msg((char*)dataptr+2, packetSize-2);
Json::Reader reader;
Json::Value value;
if (reader.parse(msg, value))
{
uint32 n = value["type"].asUInt();
if(isExist(n))
{
if(!value.isMember("data"))
{
connection->recv(SELF_PACKET_SPLITTER, EMPTY_CONTEXT);
return;
}
if(value["data"].isMember("cid"))
{
connection->recv(SELF_PACKET_SPLITTER, EMPTY_CONTEXT);
return;
}
value["data"]["cid"]=connection.get()->getSocket().getHandle();
sendToDb(value);
}
else
{
msgProcess(connection,n,value["data"]);
}
}
logger().writeFmt("Received message: %s", msg.c_str());
connection->recv(SELF_PACKET_SPLITTER, EMPTY_CONTEXT);
}
示例5: onTcpConnected
void ServerModule_Chargen::onTcpConnected(const TcpConnectionPtr& connection)
{
logger().writeFmt("onTcpConnected (%s) (ConnCount: %d)",
connection->getPeerAddr().getDisplayStr().c_str(),
connection->getServerConnCount());
connection->setNoDelay(true);
connection->recv();
connection->send(message_.c_str(), message_.length());
}
示例6: onTcpConnected
//-----------------------------------------------------------------------------
// 描述: 接受了一个新的TCP连接
//-----------------------------------------------------------------------------
void AppBusiness::onTcpConnected(const TcpConnectionPtr& connection)
{
logger().writeFmt("onTcpConnected (%s) (ConnCount: %d)",
connection->getPeerAddr().getDisplayStr().c_str(),
connection->getServerConnCount());
//string msg = "Welcome to the simple echo server, type 'quit' to exit.\r\n";
//ConnetManager::instance().add(connection);
connection->recv(SELF_PACKET_SPLITTER, EMPTY_CONTEXT);
}
示例7: onTcpRecvComplete
void AppBusiness::onTcpRecvComplete(const TcpConnectionPtr& connection, void *packetBuffer,
int packetSize, const Context& context)
{
string msg((const char*)packetBuffer, packetSize);
logger().writeFmt("[%s] Discarded %u bytes.",
connection->getConnectionName().c_str(), packetSize);
std::cout << msg;
connection->recv();
}
示例8: onTcpSendComplete
void AppBusiness::onTcpSendComplete(const TcpConnectionPtr& connection, const Context& context)
{
logger().writeStr("onTcpSendComplete");
connection->recv(LINE_PACKET_SPLITTER);
}