85 Star 237 Fork 92

yedf / handy

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
codec-svr.cc 673 Bytes
一键复制 编辑 原始数据 按行查看 历史
yedf 提交于 2015-08-14 14:25 . add startServer for TcpServer HSHA
#include <handy/handy.h>
using namespace std;
using namespace handy;
int main(int argc, const char* argv[]) {
Logger::getLogger().setLogLevel(Logger::LTRACE);
EventBase base;
Signal::signal(SIGINT, [&]{ base.exit(); });
TcpServerPtr echo = TcpServer::startServer(&base, "", 99);
exitif(echo == NULL, "start tcp server failed");
echo->onConnCreate([]{
TcpConnPtr con(new TcpConn);
con->onMsg(new LengthCodec, [](const TcpConnPtr& con, Slice msg) {
info("recv msg: %.*s", (int)msg.size(), msg.data());
con->sendMsg(msg);
});
return con;
});
base.loop();
info("program exited");
}
C++
1
https://gitee.com/yedf/handy.git
git@gitee.com:yedf/handy.git
yedf
handy
handy
master

搜索帮助