49 #define MSECS_IDLE_TIMEOUT_DEFAULT 60000 50 #define MSECS_ACTIVE_TIMEOUT_DEFAULT 15000 52 #define PROG_NAME "xapian-tcpsrv" 53 #define PROG_DESC "TCP daemon for use with Xapian's remote backend" 58 static const char *
opts =
"I:p:a:i:t:oqw";
74 cout <<
"Usage: " PROG_NAME " [OPTIONS] DATABASE_PATH...\n\n" 76 " --port PORTNUM listen on port PORTNUM for connections (no default)\n" 77 " --interface ADDRESS listen on the interface associated with name or\n" 78 " address ADDRESS (default is all interfaces)\n" 79 " --idle-timeout MSECS set timeout for idle connections (default: " 81 " --active-timeout MSECS set timeout for active connections (default: " 83 " --timeout MSECS set both timeout values\n" 84 " --one-shot serve a single connection and exit\n" 85 " --quiet disable information messages to stdout\n" 86 " --writable allow updates\n" 87 " --help display this help and exit\n" 88 " --version output version information and exit\n";
91 int main(
int argc,
char **argv) {
97 bool one_shot =
false;
99 bool writable =
false;
100 bool syntax_error =
false;
117 if (port <= 0 || port >= 65536) {
118 cerr <<
"Error: must specify a valid port number " 119 "(between 1 and 65535). " 120 "We actually got " << port <<
'\n';
125 active_timeout = atoi(
optarg) * 1e-3;
128 idle_timeout = atoi(
optarg) * 1e-3;
131 active_timeout = idle_timeout = atoi(
optarg) * 1e-3;
147 if (syntax_error || argv[
optind] == NULL) {
153 cerr <<
"Error: You must specify a port with --port\n";
162 for (
auto& dbname : dbnames) {
176 cout <<
" server on";
178 cout <<
" host " << host <<
",";
179 cout <<
" port " << port <<
'\n';
183 idle_timeout, writable, verbose);
186 cout <<
"Listening...\n" << flush;
198 }
catch (
const exception &e) {
199 cerr <<
"Caught standard exception: " << e.what() <<
'\n';
202 cerr <<
"Caught unknown exception\n";
Wrappers to allow GNU getopt to be used cleanly from C++ code.
static void register_user_weighting_schemes(RemoteTcpServer &server)
This class is used to access a database, or a group of databases.
int gnu_getopt_long(int argc_, char *const *argv_, const char *shortopts_, const struct option *longopts_, int *optind_)
Constants in the Xapian namespace.
#define STRINGIZE(X)
The STRINGIZE macro converts its parameter into a string constant.
static const char * dbnames
const int DB_CREATE_OR_OPEN
Create database if it doesn't already exist.
static const struct option long_opts[]
TCP/IP socket based server for RemoteDatabase.
Hierarchy of classes which Xapian can throw as exceptions.
int main(int argc, char **argv)
TCP/IP socket based server for RemoteDatabase.
This class provides read/write access to a database.
void set_registry(const Xapian::Registry ®_)
Set the registry used for (un)serialisation.
Registry for user subclasses.
Xapian remote backend server base class.
#define required_argument
std::string get_description() const
Return a string describing this object.
#define MSECS_IDLE_TIMEOUT_DEFAULT
#define MSECS_ACTIVE_TIMEOUT_DEFAULT
All exceptions thrown by Xapian are subclasses of Xapian::Error.
Various handy helpers which std::string really should provide.