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 (port < 1 || port > 65535)) {
118 cerr <<
"Error: must specify a valid port number "
119 "(between 1 and 65535).\n";
126 cerr <<
"Active timeout must be >= 0\n";
129 active_timeout = active * 1e-3;
135 cerr <<
"Idle timeout must be >= 0\n";
138 idle_timeout = idle * 1e-3;
142 unsigned int timeout;
144 cerr <<
"timeout must be >= 0\n";
147 active_timeout = idle_timeout = timeout * 1e-3;
164 if (syntax_error || argv[
optind] == NULL) {
170 cerr <<
"Error: You must specify a port with --port\n";
193 cout <<
" server on";
195 cout <<
" host " << host <<
",";
196 cout <<
" port " << port <<
'\n';
200 idle_timeout, writable,
verbose);
203 cout <<
"Listening...\n" << flush;
213 cerr << e.get_description() <<
'\n';
215 }
catch (
const exception &e) {
216 cerr <<
"Caught standard exception: " << e.what() <<
'\n';
219 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.
An indexed database of documents.
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.
Parse signed and unsigned type from string and check for trailing characters.
bool parse_signed(const char *p, T &res)
bool parse_unsigned(const char *p, T &res)
Xapian remote backend server base class.
TCP/IP socket based server for RemoteDatabase.
Various handy string-related helpers.
#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