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";
176 cout <<
" server on";
178 cout <<
" host " << host <<
",";
179 cout <<
" port " << port <<
'\n';
183 idle_timeout, writable,
verbose);
186 cout <<
"Listening...\n" << flush;
196 cerr << e.get_description() <<
'\n';
198 }
catch (
const exception &e) {
199 cerr <<
"Caught standard exception: " << e.what() <<
'\n';
202 cerr <<
"Caught unknown exception\n";
TCP/IP socket based server for RemoteDatabase.
void set_registry(const Xapian::Registry ®_)
Set the registry used for (un)serialisation.
This class is used to access a database, or a group of databases.
All exceptions thrown by Xapian are subclasses of Xapian::Error.
Registry for user subclasses.
This class provides read/write access to a database.
Constants in the Xapian namespace.
Hierarchy of classes which Xapian can throw as exceptions.
static const char * dbnames
Wrappers to allow GNU getopt to be used cleanly from C++ code.
#define required_argument
int gnu_getopt_long(int argc_, char *const *argv_, const char *shortopts_, const struct option *longopts_, int *optind_)
const int DB_CREATE_OR_OPEN
Create database if it doesn't already exist.
Xapian remote backend server base class.
TCP/IP socket based server for RemoteDatabase.
Various handy helpers which std::string really should provide.
#define STRINGIZE(X)
The STRINGIZE macro converts its parameter into a string constant.
int main(int argc, char **argv)
#define MSECS_IDLE_TIMEOUT_DEFAULT
static const struct option long_opts[]
static void register_user_weighting_schemes(RemoteTcpServer &server)
#define MSECS_ACTIVE_TIMEOUT_DEFAULT