00001
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef XAPIAN_INCLUDED_TCPSERVER_H
00022 #define XAPIAN_INCLUDED_TCPSERVER_H
00023
00024 #include <xapian/database.h>
00025 #include <xapian/visibility.h>
00026
00027 #ifdef __WIN32__
00028 # include "remoteconnection.h"
00029 # define SOCKET_INITIALIZER_MIXIN : private WinsockInitializer
00030 #else
00031 # define SOCKET_INITIALIZER_MIXIN
00032 #endif
00033
00034 #if defined __CYGWIN__ || defined __WIN32__
00035 # include "safewindows.h"
00036 #endif
00037
00042 class XAPIAN_VISIBILITY_DEFAULT TcpServer SOCKET_INITIALIZER_MIXIN {
00044 void operator=(const TcpServer &);
00045
00047 TcpServer(const TcpServer &);
00048
00053 const std::vector<std::string> dbpaths;
00054
00056 bool writable;
00057
00058 #if defined __CYGWIN__ || defined __WIN32__
00060 HANDLE mutex;
00061 #endif
00062
00064 int listen_socket;
00065
00067 int msecs_active_timeout;
00068
00070 int msecs_idle_timeout;
00071
00073 bool verbose;
00074
00081 static int get_listening_socket(const std::string & host, int port
00082 #if defined __CYGWIN__ || defined __WIN32__
00083 , HANDLE &mutex
00084 #endif
00085 );
00086
00088 int accept_connection();
00089
00090 public:
00106 TcpServer(const std::vector<std::string> &dbpaths_,
00107 const std::string &host, int port,
00108 int msecs_active_timeout,
00109 int msecs_idle_timeout,
00110 bool writable,
00111 bool verbose);
00112
00114 ~TcpServer();
00115
00122 void run();
00123
00125 void run_once();
00126
00132 void handle_one_connection(int socket);
00133 };
00134
00135 #endif // XAPIAN_INCLUDED_TCPSERVER_H