2 * Copyright (c) 1998-2000, Index Data.
3 * See the file LICENSE for details.
5 * $Log: yaz-server.cpp,v $
6 * Revision 1.11 2000-09-12 16:23:49 adam
7 * Updated server example.
9 * Revision 1.10 2000/09/12 16:04:17 adam
10 * Added comstack method for Yaz_PDU_Assoc..
12 * Revision 1.9 2000/09/12 12:09:53 adam
13 * More work on high-level server.
15 * Revision 1.8 2000/09/08 10:23:42 adam
16 * Added skeleton of yaz-z-server.
18 * Revision 1.7 1999/12/06 13:52:45 adam
19 * Modified for new location of YAZ header files. Experimental threaded
22 * Revision 1.6 1999/04/21 12:09:01 adam
23 * Many improvements. Modified to proxy server to work with "sessions"
26 * Revision 1.5 1999/04/09 11:46:57 adam
27 * Added object Yaz_Z_Assoc. Much more functional client.
29 * Revision 1.4 1999/03/23 14:17:57 adam
30 * More work on timeout handling. Work on yaz-client.
32 * Revision 1.3 1999/02/02 14:01:22 adam
33 * First WIN32 port of YAZ++.
35 * Revision 1.2 1999/01/28 13:08:47 adam
36 * Yaz_PDU_Assoc better encapsulated. Memory leak fix in
37 * yaz-socket-manager.cc.
39 * Revision 1.1.1.1 1999/01/28 09:41:07 adam
40 * First implementation of YAZ++.
45 #include <yaz-z-server.h>
46 #include <yaz-pdu-assoc.h>
47 #include <yaz-socket-manager.h>
49 class MyServer : public Yaz_Z_Server {
51 MyServer(IYaz_PDU_Observable *the_PDU_Observable);
52 void recv_Z_init (Z_InitRequest *initRequest,
53 Z_InitResponse *initResponse);
54 void recv_Z_search (Z_SearchRequest *searchRequest,
55 Z_SearchResponse *searchResponse);
56 void recv_Z_present (Z_PresentRequest *presentRequest,
57 Z_PresentResponse *presentResponse);
59 void recv_Z_record (const char *resultSetName,
62 Z_RecordComposition *comp,
63 Z_NamePlusRecord *namePlusRecord,
64 Z_DefaultDiagFormat *diagnostics);
65 IYaz_PDU_Observer* clone(IYaz_PDU_Observable *the_PDU_Observable);
73 void MyServer::recv_Z_init (Z_InitRequest *initRequest,
74 Z_InitResponse *initResponse)
76 logf (LOG_LOG, "MyServer::recv_Z_init");
79 static MyServer *myServer = 0;
81 void MyServer::recv_Z_search (Z_SearchRequest *searchRequest,
82 Z_SearchResponse *searchResponse)
84 logf (LOG_LOG, "MyServer::recv_Z_search");
88 void MyServer::recv_Z_present (Z_PresentRequest *presentRequest,
89 Z_PresentResponse *presentResponse)
91 logf (LOG_LOG, "MyServer::recv_Z_present");
94 void MyServer::recv_Z_record (const char *resultSetName,
97 Z_RecordComposition *comp,
98 Z_NamePlusRecord *namePlusRecord,
99 Z_DefaultDiagFormat *diagnostics)
104 IYaz_PDU_Observer *MyServer::clone(IYaz_PDU_Observable *the_PDU_Observable)
106 MyServer *new_server;
107 logf (LOG_LOG, "child no %d", m_no);
109 new_server = new MyServer(the_PDU_Observable);
110 new_server->timeout(60);
114 MyServer::MyServer(IYaz_PDU_Observable *the_PDU_Observable) :
115 Yaz_Z_Server (the_PDU_Observable)
120 void MyServer::timeoutNotify()
122 logf (LOG_LOG, "connection timed out");
126 void MyServer::failNotify()
128 logf (LOG_LOG, "connection closed by client");
132 void MyServer::connectNotify()
136 int main(int argc, char **argv)
140 Yaz_SocketManager mySocketManager;
141 Yaz_PDU_Assoc *my_PDU_Assoc = new Yaz_PDU_Assoc(&mySocketManager);
143 myServer = new MyServer(my_PDU_Assoc);
145 MyServer *z = myServer;
151 for (int i = 1; i < argc; i++)
154 COMSTACK cs = my_PDU_Assoc->comstack();
156 printf ("fd=%d\n", cs_fileno(cs));
157 while (mySocketManager.processEvent() > 0)
159 logf (LOG_LOG, "bailing out");