| 1 |
// Copyright © 2002 Rob Kaper <[email protected]>. |
| 2 |
// 2010-2015 Sylvain Rochet <[email protected]> |
| 3 |
// |
| 4 |
// This program is free software; you can redistribute it and/or |
| 5 |
// modify it under the terms of the GNU General Public License |
| 6 |
// version 2 as published by the Free Software Foundation. |
| 7 |
// |
| 8 |
// This program is distributed in the hope that it will be useful, |
| 9 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 |
// General Public License for more details. |
| 12 |
// |
| 13 |
// You should have received a copy of the GNU General Public License |
| 14 |
// along with this program; see the file COPYING. If not, see |
| 15 |
// <http://www.gnu.org/licenses/>. |
| 16 |
|
| 17 |
#ifndef NETWORK_LISTENPORT_H |
| 18 |
#define NETWORK_LISTENPORT_H |
| 19 |
|
| 20 |
#include <string> |
| 21 |
|
| 22 |
#define LISTENQ 1024 |
| 23 |
|
| 24 |
class ListenPort |
| 25 |
{ |
| 26 |
public: |
| 27 |
ListenPort(sa_family_t family, const std::string host, const int port); // for a traditional bind socket |
| 28 |
ListenPort(int fd); // for an already bound socket (e.g. using systemd socket activation) |
| 29 |
const std::string ipAddr() { return m_ipAddr; } |
| 30 |
int port() { return m_port; } |
| 31 |
int fd() { return m_fd; } |
| 32 |
int error() { return m_error; }; |
| 33 |
|
| 34 |
private: |
| 35 |
std::string m_ipAddr; |
| 36 |
int m_fd, m_port; |
| 37 |
int m_error = 0; |
| 38 |
}; |
| 39 |
|
| 40 |
#endif // NETWORK_LISTENPORT_H |