summaryrefslogtreecommitdiff
path: root/src/tcp_listener.hpp
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2011-07-26 00:43:57 +0200
committerMartin Sustrik <sustrik@250bpm.com>2011-07-26 00:43:57 +0200
commit9119b4fd7b292b1a14db916040f8e7cc4731d4b6 (patch)
tree01786d8c6418179fda8826ced4dc6c436f7da33e /src/tcp_listener.hpp
parent43b5b3444c5ea54fa17eab2e03b7e00c022f33b4 (diff)
TCP transport classes simplified
zmq_engine and tcp_socket merged into tcp_engine zmq_connecter and tcp_connecter merged into tcp_connecter zmq_listener and tcp_listener merged into tcp_listener Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src/tcp_listener.hpp')
-rw-r--r--src/tcp_listener.hpp36
1 files changed, 23 insertions, 13 deletions
diff --git a/src/tcp_listener.hpp b/src/tcp_listener.hpp
index 27e3092..2dd43ce 100644
--- a/src/tcp_listener.hpp
+++ b/src/tcp_listener.hpp
@@ -23,37 +23,41 @@
#include "fd.hpp"
#include "ip.hpp"
+#include "own.hpp"
+#include "io_object.hpp"
+#include "stdint.hpp"
namespace zmq
{
- // The class encapsulating simple TCP listening socket.
-
- class tcp_listener_t
+ class tcp_listener_t : public own_t, public io_object_t
{
public:
- tcp_listener_t ();
+ tcp_listener_t (class io_thread_t *io_thread_,
+ class socket_base_t *socket_, const options_t &options_);
~tcp_listener_t ();
- // Start listening on the interface.
- int set_address (const char *protocol_, const char *addr_,
- int backlog_);
+ // Set address to listen on.
+ int set_address (const char* protocol_, const char *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.
int close ();
- // Get the file descriptor to poll on to get notified about
- // newly created connections.
- fd_t get_fd ();
-
// 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.
fd_t accept ();
- private:
-
// Address to listen on.
sockaddr_storage addr;
socklen_t addr_len;
@@ -64,6 +68,12 @@ namespace zmq
// Underlying socket.
fd_t s;
+ // Handle corresponding to the listening socket.
+ handle_t handle;
+
+ // Socket the listerner belongs to.
+ class socket_base_t *socket;
+
tcp_listener_t (const tcp_listener_t&);
const tcp_listener_t &operator = (const tcp_listener_t&);
};