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