2 * Copyright (c) 1998-1999, Index Data.
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
6 * $Log: yaz-server.cpp,v $
7 * Revision 1.7 1999-12-06 13:52:45 adam
8 * Modified for new location of YAZ header files. Experimental threaded
11 * Revision 1.6 1999/04/21 12:09:01 adam
12 * Many improvements. Modified to proxy server to work with "sessions"
15 * Revision 1.5 1999/04/09 11:46:57 adam
16 * Added object Yaz_Z_Assoc. Much more functional client.
18 * Revision 1.4 1999/03/23 14:17:57 adam
19 * More work on timeout handling. Work on yaz-client.
21 * Revision 1.3 1999/02/02 14:01:22 adam
22 * First WIN32 port of YAZ++.
24 * Revision 1.2 1999/01/28 13:08:47 adam
25 * Yaz_PDU_Assoc better encapsulated. Memory leak fix in
26 * yaz-socket-manager.cc.
28 * Revision 1.1.1.1 1999/01/28 09:41:07 adam
29 * First implementation of YAZ++.
34 #include <yaz-z-assoc.h>
35 #include <yaz-pdu-assoc.h>
36 #include <yaz-socket-manager.h>
38 class MyServer : public Yaz_Z_Assoc {
40 MyServer(IYaz_PDU_Observable *the_PDU_Observable);
41 void recv_Z_PDU(Z_APDU *apdu);
42 IYaz_PDU_Observer* clone(IYaz_PDU_Observable *the_PDU_Observable);
52 void MyServer::recv_Z_PDU(Z_APDU *apdu)
54 logf (LOG_LOG, "recv_Z_PDU");
57 case Z_APDU_initRequest:
58 logf (LOG_LOG, "got InitRequest");
59 apdu = create_Z_PDU(Z_APDU_initResponse);
62 case Z_APDU_searchRequest:
63 logf (LOG_LOG, "got searchRequest");
64 apdu = create_Z_PDU(Z_APDU_searchResponse);
67 case Z_APDU_presentRequest:
68 logf (LOG_LOG, "got presentRequest");
69 apdu = create_Z_PDU(Z_APDU_presentResponse);
76 IYaz_PDU_Observer *MyServer::clone(IYaz_PDU_Observable *the_PDU_Observable)
79 logf (LOG_LOG, "child no %d", m_no);
81 new_server = new MyServer(the_PDU_Observable);
82 new_server->timeout(60);
86 MyServer::MyServer(IYaz_PDU_Observable *the_PDU_Observable) :
87 Yaz_Z_Assoc (the_PDU_Observable)
92 void MyServer::timeoutNotify()
94 logf (LOG_LOG, "connection timed out");
98 void MyServer::failNotify()
100 logf (LOG_LOG, "connection closed by client");
104 void MyServer::connectNotify()
108 int main(int argc, char **argv)
110 Yaz_SocketManager mySocketManager;
111 Yaz_PDU_Assoc *my_PDU_Assoc = new Yaz_PDU_Assoc(&mySocketManager);
113 MyServer z(my_PDU_Assoc);
119 for (int i = 1; i < argc; i++)
122 while (!stop && mySocketManager.processEvent() > 0)