2 * Copyright (c) 1998-2000, Index Data.
3 * See the file LICENSE for details.
5 * $Log: yaz-server.cpp,v $
6 * Revision 1.10 2000-09-12 16:04:17 adam
7 * Added comstack method for Yaz_PDU_Assoc..
9 * Revision 1.9 2000/09/12 12:09:53 adam
10 * More work on high-level server.
12 * Revision 1.8 2000/09/08 10:23:42 adam
13 * Added skeleton of yaz-z-server.
15 * Revision 1.7 1999/12/06 13:52:45 adam
16 * Modified for new location of YAZ header files. Experimental threaded
19 * Revision 1.6 1999/04/21 12:09:01 adam
20 * Many improvements. Modified to proxy server to work with "sessions"
23 * Revision 1.5 1999/04/09 11:46:57 adam
24 * Added object Yaz_Z_Assoc. Much more functional client.
26 * Revision 1.4 1999/03/23 14:17:57 adam
27 * More work on timeout handling. Work on yaz-client.
29 * Revision 1.3 1999/02/02 14:01:22 adam
30 * First WIN32 port of YAZ++.
32 * Revision 1.2 1999/01/28 13:08:47 adam
33 * Yaz_PDU_Assoc better encapsulated. Memory leak fix in
34 * yaz-socket-manager.cc.
36 * Revision 1.1.1.1 1999/01/28 09:41:07 adam
37 * First implementation of YAZ++.
42 #include <yaz-z-server.h>
43 #include <yaz-pdu-assoc.h>
44 #include <yaz-socket-manager.h>
46 class MyServer : public Yaz_Z_Server {
48 MyServer(IYaz_PDU_Observable *the_PDU_Observable);
49 void recv_Z_init (Z_InitRequest *initRequest,
50 Z_InitResponse *initResponse);
51 void recv_Z_search (Z_SearchRequest *searchRequest,
52 Z_SearchResponse *searchResponse);
53 void recv_Z_present (Z_PresentRequest *presentRequest,
54 Z_PresentResponse *presentResponse);
56 void recv_Z_record (const char *resultSetName,
59 Z_RecordComposition *comp,
60 Z_NamePlusRecord *namePlusRecord,
61 Z_DefaultDiagFormat *diagnostics);
62 IYaz_PDU_Observer* clone(IYaz_PDU_Observable *the_PDU_Observable);
72 void MyServer::recv_Z_init (Z_InitRequest *initRequest,
73 Z_InitResponse *initResponse)
75 logf (LOG_LOG, "MyServer::recv_Z_init");
78 void MyServer::recv_Z_search (Z_SearchRequest *searchRequest,
79 Z_SearchResponse *searchResponse)
81 logf (LOG_LOG, "MyServer::recv_Z_search");
86 void MyServer::recv_Z_present (Z_PresentRequest *presentRequest,
87 Z_PresentResponse *presentResponse)
89 logf (LOG_LOG, "MyServer::recv_Z_present");
92 void MyServer::recv_Z_record (const char *resultSetName,
95 Z_RecordComposition *comp,
96 Z_NamePlusRecord *namePlusRecord,
97 Z_DefaultDiagFormat *diagnostics)
102 IYaz_PDU_Observer *MyServer::clone(IYaz_PDU_Observable *the_PDU_Observable)
104 MyServer *new_server;
105 logf (LOG_LOG, "child no %d", m_no);
107 new_server = new MyServer(the_PDU_Observable);
108 new_server->timeout(60);
112 MyServer::MyServer(IYaz_PDU_Observable *the_PDU_Observable) :
113 Yaz_Z_Server (the_PDU_Observable)
118 void MyServer::timeoutNotify()
120 logf (LOG_LOG, "connection timed out");
124 void MyServer::failNotify()
126 logf (LOG_LOG, "connection closed by client");
130 void MyServer::connectNotify()
134 int main(int argc, char **argv)
139 Yaz_SocketManager mySocketManager;
140 Yaz_PDU_Assoc *my_PDU_Assoc = new Yaz_PDU_Assoc(&mySocketManager);
142 MyServer *z = new MyServer(my_PDU_Assoc);
148 for (int i = 1; i < argc; i++)
151 COMSTACK cs = my_PDU_Assoc->comstack();
153 printf ("fd=%d\n", cs_fileno(cs));
154 while (!stop && mySocketManager.processEvent() > 0)
156 logf (LOG_LOG, "bailing out");