class ClientService : public ACE_Event_Handler{protected:ACE_SOCK_Stream sock_;public://返回ACE_SOCK_Stream对象引用ACE_SOCK_Stream& peer(void){return this->sock_;}int open(void){//针对输入事件向反应器登记return this->reactor()->register_handler(this, ACE_Event_Handler::READ_MASK);}// Get this handler's I/O handle.virtual ACE_HANDLE get_handle(void) const{return this->sock_.get_handle();}// Called when input is available from the client.virtual int handle_input(ACE_HANDLE fd){//printf("服务器连接上了");const size_t INPUT_SIZE = 4096;char buffer[INPUT_SIZE];int i;ssize_t recv_cnt;if ((recv_cnt = this->sock_.recv(buffer, sizeof (buffer))) <= 0){//接受到的数据为0个字节,表明对端已关闭其socket。//返回-1,表示工作已完成。return -1;}for(i=0;i<recv_cnt;i++){printf("%d",buffer[i]);}//在这里你可以对接收的数据进行处理//...return 0;}// Called when this handler is removed from the ACE_Reactor.virtual int handle_close(ACE_HANDLE handle, ACE_Reactor_Mask close_mask){ ACE_Reactor_Mask mask;mask = ACE_Event_Handler::ALL_EVENTS_MASK |ACE_Event_Handler::DONT_CALL;this->reactor()->remove_handler(this, mask);this->sock_.close();delete this;return 0;}};RT,把上面的文件.h 和.cpp分开当我把.cpp 文件如下表示时,报错,怎么修改://返回ACE_SOCK_Stream对象引用ACE_SOCK_Stream& peer(void){return this->sock_;}int open(void){//针对输入事件向反应器登记return this->reactor()->register_handler(this, ACE_Event_Handler::READ_MASK);}// Get this handler's I/O handle.......错误 4 error C2673: “peer”: 全局函数没有“this”指针 d:\新建文件夹\slq-op_io_server\clientservice.cpp 8 错误 5 error C2227: “->sock_”的左边必须指向类/结构/联合/泛型类型 d:\新建文件夹\slq-op_io_server\clientservice.cpp 8 也就是this 指的是什么,新手,麻烦帮帮忙
1 回答
吃鸡游戏
TA贡献1829条经验 获得超7个赞
ACE_SOCK_Stream& ClientService::peer(void)
{
}
int ClientService::open(void)
{
}
这是语法。
- 1 回答
- 0 关注
- 71 浏览
添加回答
举报
0/150
提交
取消