xapian-core  1.4.25
remotetcpserver.cc
Go to the documentation of this file.
1 
4 /* Copyright 1999,2000,2001 BrightStation PLC
5  * Copyright 2002 Ananova Ltd
6  * Copyright 2002,2003,2004,2005,2006,2007,2008,2010,2015 Olly Betts
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License as
10  * published by the Free Software Foundation; either version 2 of the
11  * License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
21  * USA
22  */
23 
24 #include <config.h>
25 
26 #include "remotetcpserver.h"
27 
28 #include <xapian/error.h>
29 
30 #include "remoteserver.h"
31 
32 #include <iostream>
33 
34 using namespace std;
35 
37 RemoteTcpServer::RemoteTcpServer(const vector<std::string> &dbpaths_,
38  const std::string & host, int port,
39  double active_timeout_, double idle_timeout_,
40  bool writable_, bool verbose_)
41  : TcpServer(host, port, true, verbose_),
42  dbpaths(dbpaths_), writable(writable_),
43  active_timeout(active_timeout_), idle_timeout(idle_timeout_)
44 {
45 }
46 
47 void
49 {
50  try {
51  RemoteServer sserv(dbpaths, socket, socket,
53  sserv.set_registry(reg);
54  sserv.run();
55  } catch (const Xapian::NetworkTimeoutError &e) {
56  if (verbose)
57  cerr << "Connection timed out: " << e.get_description() << '\n';
58  } catch (const Xapian::Error &e) {
59  cerr << "Got exception " << e.get_description() << '\n';
60  } catch (...) {
61  // ignore other exceptions
62  }
63 }
bool writable
Is this a WritableDatabase?
Xapian::Registry reg
Registry used for (un)serialisation.
#define true
Definition: header.h:8
Indicates a timeout expired while communicating with a remote database.
Definition: error.h:845
STL namespace.
Hierarchy of classes which Xapian can throw as exceptions.
void run()
Repeatedly accept messages from the client and process them.
double active_timeout
Timeout between messages during a single operation (in seconds).
double idle_timeout
Timeout between operations (in seconds).
static int verbose
Definition: xapian-delve.cc:47
TCP/IP socket based server for RemoteDatabase.
Xapian remote backend server base class.
void set_registry(const Xapian::Registry &reg_)
Set the registry used for (un)serialisation.
Definition: remoteserver.h:218
const std::vector< std::string > dbpaths
Paths to the databases we will open.
std::string get_description() const
Return a string describing this object.
Definition: error.cc:93
void handle_one_connection(int socket)
Handle a single connection on an already connected socket.
RemoteTcpServer(const RemoteTcpServer &)
Don&#39;t allow copying.
All exceptions thrown by Xapian are subclasses of Xapian::Error.
Definition: error.h:43
Remote backend server base class.
Definition: remoteserver.h:36