本文整理汇总了C++中TcpConnectionPtr::receive方法的典型用法代码示例。如果您正苦于以下问题:C++ TcpConnectionPtr::receive方法的具体用法?C++ TcpConnectionPtr::receive怎么用?C++ TcpConnectionPtr::receive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TcpConnectionPtr
的用法示例。
在下文中一共展示了TcpConnectionPtr::receive方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onMessage
void EchoServer::onMessage(const TcpConnectionPtr &conn)
{
string s(conn->receive());
//不要把recv任务放到线程池
//conn->send(s);
pool_.addTask(bind(&EchoServer::compute, this, s, conn));
}
示例2: onMessage
void EchoServer::onMessage(const TcpConnectionPtr &conn)
{
ifstream infile;
infile.close();
infile.clear();
infile.open("test.txt");
TextQuery tq;
tq.read_file(infile);
string s(conn->receive());
s.erase(s.size() - 2);
pool_.addTask(bind(&EchoServer::compute, this, s, conn, tq));
}
示例3: onMessage
void WordQueryServer::onMessage(const TcpConnectionPtr & conn)
{
string msg(conn->receive());
size_t pos = msg.find('\n');
msg = msg.substr(0, pos);
cout << "client:" << msg << ",size:" << msg.size() << endl;
//string ret = _wordQuery.doQuery(msg);
//cout << "result's size:" << ret.size() << endl;
//conn->send(ret);
_pool.addTask(std::bind(&WordQueryServer::doTaskThread, this, conn, msg));
}
示例4: onMessage
void onMessage(const TcpConnectionPtr &conn)
{
conn->receive();
conn->send("ACK");
}
示例5: onMessage
void QueryServer::onMessage(const TcpConnectionPtr &conn)
{
string word(conn->receive());
pool_.addTask(bind(&QueryServer::runQuery, this, word, conn));
}
示例6: onMessage
void SpcServer::onMessage(TcpConnectionPtr conn){
string msg=conn->receive();
cout << msg << endl;
MyTask task(msg, conn->fd());
_threadPool.addTask(std::bind(& MyTask::execute, task));
}