STTNet
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 宏定义 
Public 成员函数 | 所有成员列表
stt::network::EpollSingle类 参考

用epoll监听单个句柄 更多...

#include <sttnet.h>

Public 成员函数

void startListen (const int &fd, const bool &flag=true, const time::Duration &dt=time::Duration{0, 0, 20, 0, 0})
 开始监听 更多...
 
bool isListen ()
 返回epoll监听状态 更多...
 
void setFunction (std::function< bool(const int &fd)> fc)
 设置epoll触发后的处理函数 注册一个回调函数 更多...
 
void setEndFunction (std::function< void(const int &fd)> fcEnd)
 设置epoll退出前的回调函数 注册一个回调函数 更多...
 
void setTimeOutFunction (std::function< bool(const int &fd)> fcTimeOut)
 设置epoll超时后出发的回调函数 注册一个回调函数 更多...
 
bool endListen ()
 结束epoll监听 会阻塞直到epoll退出完成 更多...
 
void endListenWithSignal ()
 发送结束epoll的信号 更多...
 
void waitAndQuit (const time::Duration &t=time::Duration{0, 0, 0, 10, 10})
 开始退出epoll倒计时,直到套接字有新的消息 如果套接字倒计时结束还没有新的消息,那么退出epoll 更多...
 
 ~EpollSingle ()
 EpollSingle的析构函数 调用eldListen阻塞退出epoll. 更多...
 

详细描述

用epoll监听单个句柄

构造及析构函数说明

stt::network::EpollSingle::~EpollSingle ( )
inline

EpollSingle的析构函数 调用eldListen阻塞退出epoll.

成员函数说明

bool stt::network::EpollSingle::endListen ( )

结束epoll监听 会阻塞直到epoll退出完成

返回
true:处理结束 false:结束失败
void stt::network::EpollSingle::endListenWithSignal ( )
inline

发送结束epoll的信号

注解
仅仅发送信号,不跟进后续逻辑
bool stt::network::EpollSingle::isListen ( )
inline

返回epoll监听状态

返回
true:正在监听 false:没有监听
void stt::network::EpollSingle::setEndFunction ( std::function< void(const int &fd)>  fcEnd)
inline

设置epoll退出前的回调函数 注册一个回调函数

参数
fcEnd一个函数或函数对象,用于处理epoll退出前的流程 -参数:const int &fd - 要处理的套接字
注解
传入的函数应该有如下签名 void func(const int &fd)
void stt::network::EpollSingle::setFunction ( std::function< bool(const int &fd)>  fc)
inline

设置epoll触发后的处理函数 注册一个回调函数

参数
fc一个函数或函数对象,用于当有数据时上来的时候回调处理套接字fd -参数:const int &fd - 要处理的套接字 -返回: bool - 返回true成功成功,返回false处理失败
注解
传入的函数应该有如下签名 bool func(const int &fd)
如果处理失败了 会退出epoll监听(没有关闭套接字)
void stt::network::EpollSingle::setTimeOutFunction ( std::function< bool(const int &fd)>  fcTimeOut)
inline

设置epoll超时后出发的回调函数 注册一个回调函数

参数
fc一个函数或函数对象,用于当epoll超时的时候回调处理套接字fd -参数:const int &fd - 要处理的套接字 -返回: bool - 返回true成功成功,返回false处理失败
注解
传入的函数应该有如下签名 bool func(const int &fd)
如果处理失败了 会退出epoll监听(没有关闭套接字)
void stt::network::EpollSingle::startListen ( const int &  fd,
const bool &  flag = true,
const time::Duration dt = time::Duration{0, 0, 20, 0, 0} 
)

开始监听

参数
fd需要监听的句柄
flagtrue:水平触发 false:边缘触发
dt填入监听超时时间
void stt::network::EpollSingle::waitAndQuit ( const time::Duration t = time::Duration{0,0,0,10,10})
inline

开始退出epoll倒计时,直到套接字有新的消息 如果套接字倒计时结束还没有新的消息,那么退出epoll

参数
t一个Duration对象 填入倒计时时长 (默认为10秒)

该类的文档由以下文件生成: