2 * Copyright (c) 1998-2000, Index Data.
3 * See the file LICENSE for details.
5 * $Log: yaz-server.cpp,v $
6 * Revision 1.8 2000-09-08 10:23:42 adam
7 * Added skeleton of yaz-z-server.
9 * Revision 1.7 1999/12/06 13:52:45 adam
10 * Modified for new location of YAZ header files. Experimental threaded
13 * Revision 1.6 1999/04/21 12:09:01 adam
14 * Many improvements. Modified to proxy server to work with "sessions"
17 * Revision 1.5 1999/04/09 11:46:57 adam
18 * Added object Yaz_Z_Assoc. Much more functional client.
20 * Revision 1.4 1999/03/23 14:17:57 adam
21 * More work on timeout handling. Work on yaz-client.
23 * Revision 1.3 1999/02/02 14:01:22 adam
24 * First WIN32 port of YAZ++.
26 * Revision 1.2 1999/01/28 13:08:47 adam
27 * Yaz_PDU_Assoc better encapsulated. Memory leak fix in
28 * yaz-socket-manager.cc.
30 * Revision 1.1.1.1 1999/01/28 09:41:07 adam
31 * First implementation of YAZ++.
36 #include <yaz-z-server.h>
37 #include <yaz-pdu-assoc.h>
38 #include <yaz-socket-manager.h>
40 class MyServer : public Yaz_Z_Server {
42 MyServer(IYaz_PDU_Observable *the_PDU_Observable);
43 void recv_Z_PDU(Z_APDU *apdu);
44 IYaz_PDU_Observer* clone(IYaz_PDU_Observable *the_PDU_Observable);
54 void MyServer::recv_Z_PDU(Z_APDU *apdu)
56 logf (LOG_LOG, "recv_Z_PDU");
59 case Z_APDU_initRequest:
60 logf (LOG_LOG, "got InitRequest");
61 apdu = create_Z_PDU(Z_APDU_initResponse);
64 case Z_APDU_searchRequest:
65 logf (LOG_LOG, "got searchRequest");
66 apdu = create_Z_PDU(Z_APDU_searchResponse);
69 case Z_APDU_presentRequest:
70 logf (LOG_LOG, "got presentRequest");
71 apdu = create_Z_PDU(Z_APDU_presentResponse);
78 IYaz_PDU_Observer *MyServer::clone(IYaz_PDU_Observable *the_PDU_Observable)
81 logf (LOG_LOG, "child no %d", m_no);
83 new_server = new MyServer(the_PDU_Observable);
84 new_server->timeout(60);
88 MyServer::MyServer(IYaz_PDU_Observable *the_PDU_Observable) :
89 Yaz_Z_Server (the_PDU_Observable)
94 void MyServer::timeoutNotify()
96 logf (LOG_LOG, "connection timed out");
100 void MyServer::failNotify()
102 logf (LOG_LOG, "connection closed by client");
106 void MyServer::connectNotify()
110 int main(int argc, char **argv)
112 Yaz_SocketManager mySocketManager;
113 Yaz_PDU_Assoc *my_PDU_Assoc = new Yaz_PDU_Assoc(&mySocketManager);
115 MyServer z(my_PDU_Assoc);
121 for (int i = 1; i < argc; i++)
124 while (!stop && mySocketManager.processEvent() > 0)