MPD: SocketMonitor Class Reference

MPD 0.20.15

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 ()
EventLoop & | GetEventLoop ()
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

## ◆ ssize_t

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

Definition at line 69 of file SocketMonitor.hxx.

## Constructor & Destructor Documentation

## ◆ SocketMonitor() [1/2]

SocketMonitor::SocketMonitor | ( | EventLoop & | _loop | ) |
| inline

Definition at line 71 of file SocketMonitor.hxx.

## ◆ SocketMonitor() [2/2]

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

Definition at line 74 of file SocketMonitor.hxx.

## ◆ ~SocketMonitor()

SocketMonitor::~SocketMonitor | ( |  | ) |

## Member Function Documentation

## ◆ Abandon()

void SocketMonitor::Abandon | ( |  | ) |

Somebody has closed the socket.

Unregister this object.

## ◆ Cancel()

void SocketMonitor::Cancel | ( |  | ) |
| inline

Definition at line 116 of file SocketMonitor.hxx.

## ◆ CancelRead()

void SocketMonitor::CancelRead | ( |  | ) |
| inline

Definition at line 128 of file SocketMonitor.hxx.

## ◆ CancelWrite()

void SocketMonitor::CancelWrite | ( |  | ) |
| inline

Definition at line 132 of file SocketMonitor.hxx.

## ◆ Close()

void SocketMonitor::Close | ( |  | ) |

## ◆ Dispatch()

void SocketMonitor::Dispatch | ( | unsigned | flags | ) |

## ◆ Get()

int SocketMonitor::Get | ( |  | ) | const
| inline

Definition at line 87 of file SocketMonitor.hxx.

## ◆ GetEventLoop()

EventLoop& SocketMonitor::GetEventLoop | ( |  | ) |
| inline

Definition at line 79 of file SocketMonitor.hxx.

## ◆ GetScheduledFlags()

unsigned SocketMonitor::GetScheduledFlags | ( |  | ) | const
| inline

Definition at line 108 of file SocketMonitor.hxx.

## ◆ IsDefined()

bool SocketMonitor::IsDefined | ( |  | ) | const
| inline

Definition at line 83 of file SocketMonitor.hxx.

## ◆ OnSocketReady()

virtual bool SocketMonitor::OnSocketReady | ( | unsigned | flags | ) |
| protectedpure virtual

Returns
  false if the socket has been closed

Implemented in HttpdClient, BufferedSocket, and FullyBufferedSocket.

## ◆ Open()

void SocketMonitor::Open | ( | int | _fd | ) |

## ◆ Read()

ssize_t SocketMonitor::Read | ( | void * | data,
|  | size_t | length
| ) |  |

## ◆ Schedule()

void SocketMonitor::Schedule | ( | unsigned | flags | ) |

## ◆ ScheduleRead()

void SocketMonitor::ScheduleRead | ( |  | ) |
| inline

Definition at line 120 of file SocketMonitor.hxx.

## ◆ ScheduleWrite()

void SocketMonitor::ScheduleWrite | ( |  | ) |
| inline

Definition at line 124 of file SocketMonitor.hxx.

## ◆ Steal()

int SocketMonitor::Steal | ( |  | ) |

"Steal" the socket descriptor.

This abandons the socket and returns it.

## ◆ Write()

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

## Field Documentation

## ◆ ERROR

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

Definition at line 66 of file SocketMonitor.hxx.

## ◆ HANGUP

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

Definition at line 67 of file SocketMonitor.hxx.

## ◆ READ

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

Definition at line 64 of file SocketMonitor.hxx.

## ◆ WRITE

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:

- event/SocketMonitor.hxx