MPD 0.20.6

- Main Page
- Namespaces
- Data Structures
- Files

- Data Structures
- Class Hierarchy
- Data Fields

Public Member Functions | Protected Types | Protected Member Functions
BufferedSocket Class Referenceabstract

A SocketMonitor specialization that adds an input buffer. More...

`#include <BufferedSocket.hxx>`

Inheritance diagram for BufferedSocket:
[legend]
Collaboration diagram for BufferedSocket:
[legend]

## Public Member Functions
| BufferedSocket (int _fd, EventLoop &_loop)

## Protected Types
enum | InputResult { InputResult::MORE, InputResult::PAUSE, InputResult::AGAIN, InputResult::CLOSED }
Protected Types inherited from SocketMonitor
typedef std::make_signed< size_t >::type | ssize_t

## Protected Member Functions
bool | ResumeInput ()
void | ConsumeInput (size_t nbytes)
| Mark a portion of the input buffer "consumed". More...
virtual InputResult | OnSocketInput (void *data, size_t length)=0
| Data has been received on the socket. More...
virtual void | OnSocketError (std::exception_ptr ep)=0
virtual void | OnSocketClosed ()=0
virtual bool | OnSocketReady (unsigned flags) override
| 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)

## Additional Inherited Members
Static Protected Attributes inherited from SocketMonitor
static constexpr unsigned | READ = PollGroup::READ
static constexpr unsigned | WRITE = PollGroup::WRITE
static constexpr unsigned | ERROR = PollGroup::ERROR
static constexpr unsigned | HANGUP = PollGroup::HANGUP

## Detailed Description

A SocketMonitor specialization that adds an input buffer.

Definition at line 37 of file BufferedSocket.hxx.

## Member Enumeration Documentation

enum BufferedSocket::InputResult
| strong protected

Enumerator
MORE | The method was successful, and it is ready to read more data.
PAUSE | The method does not want to get more data for now. It will call ResumeInput() when it's ready for more.
AGAIN | The method wants to be called again immediately, if there's more data in the buffer.
CLOSED | The method has closed the socket.

Definition at line 78 of file BufferedSocket.hxx.

## Constructor & Destructor Documentation

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

Definition at line 41 of file BufferedSocket.hxx.

## Member Function Documentation

void BufferedSocket::ConsumeInput | ( | size_t | nbytes | ) |
| inline protected

Mark a portion of the input buffer "consumed".

Only allowed to be called from OnSocketInput(). This method does not invalidate the pointer passed to OnSocketInput() yet.

Definition at line 72 of file BufferedSocket.hxx.

virtual void BufferedSocket::OnSocketClosed | ( |  | ) |
| protected pure virtual

Implemented in HttpdClient.

virtual void BufferedSocket::OnSocketError | ( | std::exception_ptr | ep | ) |
| protected pure virtual

Implemented in HttpdClient.

virtual InputResult BufferedSocket::OnSocketInput | ( | void * | data,
|  | size_t | length
| ) |  |
| protected pure virtual

Data has been received on the socket.

Parameters

  data | a pointer to the beginning of the buffer; the buffer may be modified by the method while it processes the data

Implemented in HttpdClient.

virtual bool BufferedSocket::OnSocketReady | ( | unsigned | flags | ) |
| override protected virtual

Returns
  false if the socket has been closed

Implements SocketMonitor.

Reimplemented in HttpdClient, and FullyBufferedSocket.

bool BufferedSocket::ResumeInput | ( |  | ) |
| protected

Returns
  false if the socket has been closed

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

- event/BufferedSocket.hxx