Problem: duplication across ipc_listener_t, tcp_listener_t, tipc_listener_t

Solution: extract common base class stream_listener_base_t
This commit is contained in:
Simon Giesecke
2019-01-31 10:52:51 -05:00
parent a40a3b7a34
commit 93c1843f3e
10 changed files with 206 additions and 196 deletions

View File

@@ -37,23 +37,17 @@
#include <string>
#include "fd.hpp"
#include "own.hpp"
#include "stdint.hpp"
#include "io_object.hpp"
#include "stream_listener_base.hpp"
#include "tipc_address.hpp"
namespace zmq
{
class io_thread_t;
class socket_base_t;
class tipc_listener_t : public own_t, public io_object_t
class tipc_listener_t : public stream_listener_base_t
{
public:
tipc_listener_t (zmq::io_thread_t *io_thread_,
zmq::socket_base_t *socket_,
const options_t &options_);
~tipc_listener_t ();
// Set address to listen on.
int set_address (const char *addr_);
@@ -62,16 +56,9 @@ class tipc_listener_t : public own_t, public io_object_t
int get_address (std::string &addr_);
private:
// Handlers for incoming commands.
void process_plug ();
void process_term (int linger_);
// Handlers for I/O events.
void in_event ();
// Close the listening socket.
void close ();
// Accept the new connection. Returns the file descriptor of the
// newly created connection. The function may return retired_fd
// if the connection was dropped while waiting in the listen backlog.
@@ -80,18 +67,6 @@ class tipc_listener_t : public own_t, public io_object_t
// Address to listen on
tipc_address_t _address;
// Underlying socket.
fd_t _s;
// Handle corresponding to the listening socket.
handle_t _handle;
// Socket the listener belongs to.
zmq::socket_base_t *_socket;
// String representation of endpoint to bind to
std::string _endpoint;
tipc_listener_t (const tipc_listener_t &);
const tipc_listener_t &operator= (const tipc_listener_t &);
};