STTNet
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | List of all members
stt::network::EpollSingle Class Reference

Listen to a single handle with epoll. More...

#include <sttnet_English.h>

Public Member Functions

void startListen (const int &fd, const bool &flag=true, const time::Duration &dt=time::Duration{0, 0, 20, 0, 0})
 Start listening. More...
 
bool isListen ()
 Return epoll listening status. More...
 
void setFunction (std::function< bool(const int &fd)> fc)
 Set the processing function after epoll triggering Register a callback function. More...
 
void setEndFunction (std::function< void(const int &fd)> fcEnd)
 Set the callback function before epoll exits Register a callback function. More...
 
void setTimeOutFunction (std::function< bool(const int &fd)> fcTimeOut)
 Set the callback function triggered after epoll timeout Register a callback function. More...
 
bool endListen ()
 End epoll listening Will block until epoll exits completely. More...
 
void endListenWithSignal ()
 Send a signal to end epoll. More...
 
void waitAndQuit (const time::Duration &t=time::Duration{0, 0, 0, 10, 10})
 Start the epoll exit countdown until new messages arrive on the socket If no new messages arrive by the end of the countdown, epoll will exit. More...
 
 ~EpollSingle ()
 Destructor of EpollSingle Calls eldListen to block and exit epoll. More...
 

Detailed Description

Listen to a single handle with epoll.

Constructor & Destructor Documentation

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

Destructor of EpollSingle Calls eldListen to block and exit epoll.

Member Function Documentation

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

End epoll listening Will block until epoll exits completely.

Returns
true: Processing ended, false: Ending failed
void stt::network::EpollSingle::endListenWithSignal ( )
inline

Send a signal to end epoll.

Note
Only sends the signal, does not follow up on subsequent logic
bool stt::network::EpollSingle::isListen ( )
inline

Return epoll listening status.

Returns
true: Listening, false: Not listening
void stt::network::EpollSingle::setEndFunction ( std::function< void(const int &fd)>  fcEnd)
inline

Set the callback function before epoll exits Register a callback function.

Parameters
fcEndA function or function object for processing the epoll exit process
  • Parameter: const int &fd - Socket to be processed
Note
The passed function should have the signature void func(const int &fd)
void stt::network::EpollSingle::setFunction ( std::function< bool(const int &fd)>  fc)
inline

Set the processing function after epoll triggering Register a callback function.

Parameters
fcA function or function object for callback processing when data is available
  • Parameter: const int &fd - Socket to be processed
  • Return: bool - true for successful processing, false for processing failure
Note
The passed function should have the signature bool func(const int &fd)
If processing fails, epoll listening will exit (socket is not closed)
void stt::network::EpollSingle::setTimeOutFunction ( std::function< bool(const int &fd)>  fcTimeOut)
inline

Set the callback function triggered after epoll timeout Register a callback function.

Parameters
fcA function or function object for callback processing when epoll times out
  • Parameter: const int &fd - Socket to be processed
  • Return: bool - true for successful processing, false for processing failure
Note
The passed function should have the signature bool func(const int &fd)
If processing fails, epoll listening will exit (socket is not closed)
void stt::network::EpollSingle::startListen ( const int &  fd,
const bool &  flag = true,
const time::Duration dt = time::Duration{0, 0, 20, 0, 0} 
)

Start listening.

Parameters
fdHandle to be listened to
flagtrue: Level triggering, false: Edge triggering
dtListening timeout duration
void stt::network::EpollSingle::waitAndQuit ( const time::Duration t = time::Duration{0,0,0,10,10})
inline

Start the epoll exit countdown until new messages arrive on the socket If no new messages arrive by the end of the countdown, epoll will exit.

Parameters
tA Duration object for the countdown duration (default is 10 seconds)

The documentation for this class was generated from the following file: