From 9119b4fd7b292b1a14db916040f8e7cc4731d4b6 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Tue, 26 Jul 2011 00:43:57 +0200 Subject: 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 --- src/tcp_listener.hpp | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'src/tcp_listener.hpp') 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&); }; -- cgit v1.2.3