1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
Lookup has been hacked to act in server mode, where it listens for
connections on a socket. Compile with -DSERVER_CONFIG. This allows
programs to access it for searching.
It is not very well done. There can only be one client at a time (i.e.
while working with one client, it doesn't listen for others). Also, the
server shouldn't be a separately-compiled program, but just an option.
Some day.
As it is, you probably want to rename the 'lookup' binary to something like
'lookup.srv' for the server.
When starting the server, -verbose means that the server should be a bit
verbose about what commands it is getting, while '-port ####' allows you to
override the port number defined in config.h. No RC file is read when running
as a server.
The client sends commands to the server. As with regular 'lookup', most
command lines are search patterns (although you may append ",1" etc. for
accessing multiple files). As with regular 'lookup', non-search commands
are required to be a prefixed by a space (or whatever the command-prefix
character is).
***************
** Note that the lines sent by the client should NOT have a newline (unless
** you want the newline to be part of the pattern).
***************
There are some special commands that the client can send:
"-- -exit- --" Causes the server to exit.
I.e.
print SERVER "-- -exit- --";
(note lack of newline)
"--continuous--"
If the first command by a given client, the server will not drop
the connection after the first command has been answered. This
allows multiple question/answer sessions during one connection.
In this case, the server signals it is done with one answer by
sending "--done--\n" and then waiting for another command.
The server will respond with "--ok--\n" when the --continuous--
command has been recognized.
"--bye--"
For a --continuous-- connection, closes the connection for the
current client; server continues to wait for another client.
------------------------------------------------
There is a small perl test program "test.pl" just so you can get it
working. It requires my network.pl library, a (perhaps old) copy of which
is included here. The latest version is always at
http://www.wg.omron.co.jp/~jfriedl/perl/
jfriedl@omron.co.jp
|