MPD  0.20.6
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions
SocketMonitor Class Referenceabstract

Monitor events on a socket. More...

#include <SocketMonitor.hxx>

Inheritance diagram for SocketMonitor:
[legend]

Public Types

typedef std::make_signed< size_t >::type ssize_t
 

Public Member Functions

 SocketMonitor (EventLoop &_loop)
 
 SocketMonitor (int _fd, EventLoop &_loop)
 
 ~SocketMonitor ()
 
EventLoopGetEventLoop ()
 
bool IsDefined () const
 
int Get () const
 
void Open (int _fd)
 
int Steal ()
 "Steal" the socket descriptor. More...
 
void Abandon ()
 Somebody has closed the socket. More...
 
void Close ()
 
unsigned GetScheduledFlags () const
 
void Schedule (unsigned flags)
 
void Cancel ()
 
void ScheduleRead ()
 
void ScheduleWrite ()
 
void CancelRead ()
 
void CancelWrite ()
 
ssize_t Read (void *data, size_t length)
 
ssize_t Write (const void *data, size_t length)
 
void Dispatch (unsigned flags)
 

Static Public Attributes

static constexpr unsigned READ = PollGroup::READ
 
static constexpr unsigned WRITE = PollGroup::WRITE
 
static constexpr unsigned ERROR = PollGroup::ERROR
 
static constexpr unsigned HANGUP = PollGroup::HANGUP
 

Protected Member Functions

virtual bool OnSocketReady (unsigned flags)=0
 

Detailed Description

Monitor events on a socket.

Call Schedule() to announce events you're interested in, or Cancel() to cancel your subscription. The EventLoop will invoke virtual method OnSocketReady() as soon as any of the subscribed events are ready.

This class does not feel responsible for closing the socket. Call Close() to do it manually.

This class is not thread-safe, all methods must be called from the thread that runs the EventLoop, except where explicitly documented as thread-safe.

Definition at line 54 of file SocketMonitor.hxx.

Member Typedef Documentation

typedef std::make_signed<size_t>::type SocketMonitor::ssize_t

Definition at line 69 of file SocketMonitor.hxx.

Constructor & Destructor Documentation

SocketMonitor::SocketMonitor ( EventLoop _loop)
inline

Definition at line 71 of file SocketMonitor.hxx.

SocketMonitor::SocketMonitor ( int  _fd,
EventLoop _loop 
)
inline

Definition at line 74 of file SocketMonitor.hxx.

SocketMonitor::~SocketMonitor ( )

Member Function Documentation

void SocketMonitor::Abandon ( )

Somebody has closed the socket.

Unregister this object.

void SocketMonitor::Cancel ( )
inline

Definition at line 116 of file SocketMonitor.hxx.

void SocketMonitor::CancelRead ( )
inline

Definition at line 128 of file SocketMonitor.hxx.

void SocketMonitor::CancelWrite ( )
inline

Definition at line 132 of file SocketMonitor.hxx.

void SocketMonitor::Close ( )
void SocketMonitor::Dispatch ( unsigned  flags)
int SocketMonitor::Get ( ) const
inline

Definition at line 87 of file SocketMonitor.hxx.

EventLoop& SocketMonitor::GetEventLoop ( )
inline

Definition at line 79 of file SocketMonitor.hxx.

unsigned SocketMonitor::GetScheduledFlags ( ) const
inline

Definition at line 108 of file SocketMonitor.hxx.

bool SocketMonitor::IsDefined ( ) const
inline

Definition at line 83 of file SocketMonitor.hxx.

virtual bool SocketMonitor::OnSocketReady ( unsigned  flags)
protectedpure virtual
Returns
false if the socket has been closed

Implemented in HttpdClient, BufferedSocket, and FullyBufferedSocket.

void SocketMonitor::Open ( int  _fd)
ssize_t SocketMonitor::Read ( void *  data,
size_t  length 
)
void SocketMonitor::Schedule ( unsigned  flags)
void SocketMonitor::ScheduleRead ( )
inline

Definition at line 120 of file SocketMonitor.hxx.

void SocketMonitor::ScheduleWrite ( )
inline

Definition at line 124 of file SocketMonitor.hxx.

int SocketMonitor::Steal ( )

"Steal" the socket descriptor.

This abandons the socket and returns it.

ssize_t SocketMonitor::Write ( const void *  data,
size_t  length 
)

Field Documentation

constexpr unsigned SocketMonitor::ERROR = PollGroup::ERROR
static

Definition at line 66 of file SocketMonitor.hxx.

constexpr unsigned SocketMonitor::HANGUP = PollGroup::HANGUP
static

Definition at line 67 of file SocketMonitor.hxx.

constexpr unsigned SocketMonitor::READ = PollGroup::READ
static

Definition at line 64 of file SocketMonitor.hxx.

constexpr unsigned SocketMonitor::WRITE = PollGroup::WRITE
static

Definition at line 65 of file SocketMonitor.hxx.


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