目录
1.Task类
classTask{public:voidProcessOn(){_handler(_sock);}Task(){}Task(int sock):_sock(sock){}~Task(){}private:int _sock;
CallBack _handler;// 设置回调};
2.CallBack类
- 读取出错处理- 读取请求时可能出错,此时读取到的请求是一个错误请求,那么就没有往下解析执行的必要了,故在
RecvRequest()
返回之后,做以下设计ep->RecvRequest();if(!ep->IsStop())// 只有读取请求不出错,才往下执行{LOG(INFO,"Recv No Error, Continue Build And Send"); ep->BuildResponse(); ep->SendResponse();}else{LOG(WARNING,"Recv Error, Stop Build And Send");}
structCallBack{// 重载() --> 仿函数voidoperator()(int sock){HandlerRequest(sock);}voidHandlerRequest(int sock){LOG(INFO,"Hander Request Begin");
EndPoint *ep =newEndPoint(sock);// TODO
ep->RecvRequest();if(!ep->IsStop())// 只有读取请求不出错,才往下执行{LOG(INFO,"Recv No Error, Continue Build And Send");
ep->BuildResponse();
ep->SendResponse();}else{LOG(WARNING,"Recv Error, Stop Build And Send");}delete ep;LOG(INFO,"Hander Request End");}CallBack(){}~CallBack(){}};
本文转载自: https://blog.csdn.net/qq_37281656/article/details/142280292
版权归原作者 DieSnowK 所有, 如有侵权,请联系我们删除。
版权归原作者 DieSnowK 所有, 如有侵权,请联系我们删除。