![]() |
libzmq master
The Intelligent Transport Layer
|
00001 /* 00002 Copyright (c) 2009-2011 250bpm s.r.o. 00003 Copyright (c) 2007-2010 iMatix Corporation 00004 Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file 00005 00006 This file is part of 0MQ. 00007 00008 0MQ is free software; you can redistribute it and/or modify it under 00009 the terms of the GNU Lesser General Public License as published by 00010 the Free Software Foundation; either version 3 of the License, or 00011 (at your option) any later version. 00012 00013 0MQ is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU Lesser General Public License for more details. 00017 00018 You should have received a copy of the GNU Lesser General Public License 00019 along with this program. If not, see <http://www.gnu.org/licenses/>. 00020 */ 00021 00022 #ifndef __ZMQ_TCP_LISTENER_HPP_INCLUDED__ 00023 #define __ZMQ_TCP_LISTENER_HPP_INCLUDED__ 00024 00025 #include "fd.hpp" 00026 #include "own.hpp" 00027 #include "stdint.hpp" 00028 #include "io_object.hpp" 00029 #include "tcp_address.hpp" 00030 00031 namespace zmq 00032 { 00033 00034 class tcp_listener_t : public own_t, public io_object_t 00035 { 00036 public: 00037 00038 tcp_listener_t (class io_thread_t *io_thread_, 00039 class socket_base_t *socket_, const options_t &options_); 00040 ~tcp_listener_t (); 00041 00042 // Set address to listen on. 00043 int set_address (const char *addr_); 00044 00045 private: 00046 00047 // Handlers for incoming commands. 00048 void process_plug (); 00049 void process_term (int linger_); 00050 00051 // Handlers for I/O events. 00052 void in_event (); 00053 00054 // Close the listening socket. 00055 void close (); 00056 00057 // Accept the new connection. Returns the file descriptor of the 00058 // newly created connection. The function may return retired_fd 00059 // if the connection was dropped while waiting in the listen backlog. 00060 fd_t accept (); 00061 00062 // Address to listen on. 00063 tcp_address_t address; 00064 00065 // True, if the undelying file for UNIX domain socket exists. 00066 bool has_file; 00067 00068 // Underlying socket. 00069 fd_t s; 00070 00071 // Handle corresponding to the listening socket. 00072 handle_t handle; 00073 00074 // Socket the listerner belongs to. 00075 class socket_base_t *socket; 00076 00077 tcp_listener_t (const tcp_listener_t&); 00078 const tcp_listener_t &operator = (const tcp_listener_t&); 00079 }; 00080 00081 } 00082 00083 #endif