xapian-core  1.4.21
tcpserver.h
Go to the documentation of this file.
1 
4 /* Copyright (C) 2007,2008 Olly Betts
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of the
9  * License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef XAPIAN_INCLUDED_TCPSERVER_H
22 #define XAPIAN_INCLUDED_TCPSERVER_H
23 
24 #ifdef __WIN32__
25 # include "remoteconnection.h"
26 # define SOCKET_INITIALIZER_MIXIN : private WinsockInitializer
27 #else
28 # define SOCKET_INITIALIZER_MIXIN
29 #endif
30 
31 #if defined __CYGWIN__ || defined __WIN32__
32 # include "safewindows.h" // Only for HANDLE!
33 #endif
34 
35 #include <xapian/visibility.h>
36 
37 #include <string>
38 
45  void operator=(const TcpServer &);
46 
48  TcpServer(const TcpServer &);
49 
50 #if defined __CYGWIN__ || defined __WIN32__
51  HANDLE mutex = NULL;
53 #endif
54 
57 
65  static int get_listening_socket(const std::string & host, int port,
66  bool tcp_nodelay
67 #if defined __CYGWIN__ || defined __WIN32__
68  , HANDLE &mutex
69 #endif
70  );
71 
72  protected:
74  bool verbose;
75 
77  int accept_connection();
78 
79  public:
89  TcpServer(const std::string &host, int port, bool tcp_nodelay,
90  bool verbose);
91 
93  virtual ~TcpServer();
94 
101  void run();
102 
104  void run_once();
105 
107  virtual void handle_one_connection(int socket) = 0;
108 };
109 
110 #endif // XAPIAN_INCLUDED_TCPSERVER_H
RemoteConnection class used by the remote backend.
bool verbose
Should we produce output when connections are made or lost?
Definition: tcpserver.h:74
int listen_socket
The socket we&#39;re listening on.
Definition: tcpserver.h:56
#define XAPIAN_VISIBILITY_DEFAULT
Definition: visibility.h:28
Define XAPIAN_VISIBILITY_* macros.
include <windows.h> without all the bloat and damage.
TCP/IP replication client class.