MPD: ServerSocket Class Reference

MPD 0.20.18

Public Member Functions | Protected Member Functions | Friends
ServerSocket Class Referenceabstract

A socket that accepts incoming stream connections (e.g. More...

`#include <ServerSocket.hxx>`

Inheritance diagram for ServerSocket:
[legend]

## Public Member Functions
| ServerSocket (EventLoop &_loop)
| ~ServerSocket ()
EventLoop & | GetEventLoop ()
void | AddPort (unsigned port)
| Add a listener on a port on all interfaces. More...
void | AddHost (const char *hostname, unsigned port)
| Resolves a host name, and adds listeners on all addresses in the result set. More...
void | AddPath (AllocatedPath &&path)
| Add a listener on a Unix domain socket. More...
void | AddFD (int fd)
| Add a socket descriptor that is accepting connections. More...
void | Open ()
| Throws #std::runtime_error on error. More...
void | Close ()

## Protected Member Functions
virtual void | OnAccept (int fd, SocketAddress address, int uid)=0

## Friends
class | OneServerSocket

## Detailed Description

A socket that accepts incoming stream connections (e.g.

TCP).

Definition at line 34 of file ServerSocket.hxx.

## Constructor & Destructor Documentation

## ◆ ServerSocket()

ServerSocket::ServerSocket | ( | EventLoop & | _loop | ) |

## ◆ ~ServerSocket()

ServerSocket::~ServerSocket | ( |  | ) |

## Member Function Documentation

## ◆ AddFD()

void ServerSocket::AddFD | ( | int | fd | ) |

Add a socket descriptor that is accepting connections.

After this has been called, don't call server_socket_open(), because the socket is already open.

Throws #std::runtime_error on error.

## ◆ AddHost()

void ServerSocket::AddHost | ( | const char * | hostname,
|  | unsigned | port
| ) |  |

Resolves a host name, and adds listeners on all addresses in the result set.

Throws #std::runtime_error on error.

Parameters

  hostname | the host name to be resolved
  port | the TCP port
  error | location to store the error occurring

## ◆ AddPath()

void ServerSocket::AddPath | ( | AllocatedPath && | path | ) |

Add a listener on a Unix domain socket.

Throws #std::runtime_error on error.

Parameters

  path | the absolute socket path
  error | location to store the error occurring

## ◆ AddPort()

void ServerSocket::AddPort | ( | unsigned | port | ) |

Add a listener on a port on all interfaces.

Throws #std::runtime_error on error.

Parameters

  port | the TCP port
  error | location to store the error occurring

## ◆ Close()

void ServerSocket::Close | ( |  | ) |

## ◆ GetEventLoop()

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

Definition at line 47 of file ServerSocket.hxx.

## ◆ OnAccept()

virtual void ServerSocket::OnAccept | ( | int | fd,
|  | SocketAddress | address,
|  | int | uid
| ) |  |
| protectedpure virtual

## ◆ Open()

void ServerSocket::Open | ( |  | ) |

Throws #std::runtime_error on error.

## Friends And Related Function Documentation

## ◆ OneServerSocket

friend class OneServerSocket
| friend

Definition at line 35 of file ServerSocket.hxx.

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

- event/ServerSocket.hxx