# sim **Repository Path**: mirrors/sim ## Basic Information - **Project Name**: sim - **Description**: 一个简单的 C++ 网络服务器框架, 使用这个框架, 可以帮助你快速上手, 编写自定义的 C++ 服务器应用, 避免繁琐的网络 IO 和连接管理等细节. Sim 的报文协议设计得非 - **Primary Language**: C/C++ - **License**: BSD-3-Clause - **Default Branch**: master - **Homepage**: https://www.oschina.net/p/sim - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 3 - **Created**: 2017-11-16 - **Last Updated**: 2026-01-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # sim C++ network server framework, `nc` and `telnet` friendly. # demo #include "sim/sim.h" class MyHandler : public sim::Handler { public: virtual sim::HandlerState proc(const sim::Request &req, sim::Response *resp){ std::string cmd = req.msg.type(); if(cmd == "ping"){ resp->msg.add("ok"); resp->msg.add("pong"); }else{ resp->msg.add("ok"); resp->msg.add(cmd); } return this->resp(); } }; int main(int argc, char **argv){ const char *ip = "127.0.0.1"; int port = 8800; sim::Server *serv = sim::Server::listen(ip, port); if(!serv){ log_fatal("%s", strerror(errno)); exit(0); } log_info("server listen on %s:%d", ip, port); MyHandler handler; serv->add_handler(&handler); serv->loop(); return 0; }