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.6 1999-04-21 12:09:01 adam
8 * Many improvements. Modified to proxy server to work with "sessions"
11 * Revision 1.5 1999/04/09 11:46:57 adam
12 * Added object Yaz_Z_Assoc. Much more functional client.
14 * Revision 1.4 1999/03/23 14:17:57 adam
15 * More work on timeout handling. Work on yaz-client.
17 * Revision 1.3 1999/02/02 14:01:22 adam
18 * First WIN32 port of YAZ++.
20 * Revision 1.2 1999/01/28 13:08:47 adam
21 * Yaz_PDU_Assoc better encapsulated. Memory leak fix in
22 * yaz-socket-manager.cc.
24 * Revision 1.1.1.1 1999/01/28 09:41:07 adam
25 * First implementation of YAZ++.
30 #include <yaz-z-assoc.h>
31 #include <yaz-pdu-assoc.h>
32 #include <yaz-socket-manager.h>
34 class MyServer : public Yaz_Z_Assoc {
36 MyServer(IYaz_PDU_Observable *the_PDU_Observable);
37 void recv_Z_PDU(Z_APDU *apdu);
38 IYaz_PDU_Observer* clone(IYaz_PDU_Observable *the_PDU_Observable);
47 void MyServer::recv_Z_PDU(Z_APDU *apdu)
49 logf (LOG_LOG, "recv_Z_PDU");
52 case Z_APDU_initRequest:
53 logf (LOG_LOG, "got InitRequest");
54 apdu = create_Z_PDU(Z_APDU_initResponse);
57 case Z_APDU_searchRequest:
58 logf (LOG_LOG, "got searchRequest");
59 apdu = create_Z_PDU(Z_APDU_searchResponse);
62 case Z_APDU_presentRequest:
63 logf (LOG_LOG, "got presentRequest");
64 apdu = create_Z_PDU(Z_APDU_presentResponse);
71 IYaz_PDU_Observer *MyServer::clone(IYaz_PDU_Observable *the_PDU_Observable)
74 logf (LOG_LOG, "child no %d", m_no);
76 new_server = new MyServer(the_PDU_Observable);
77 new_server->timeout(60);
81 MyServer::MyServer(IYaz_PDU_Observable *the_PDU_Observable) :
82 Yaz_Z_Assoc (the_PDU_Observable)
87 void MyServer::timeoutNotify()
89 logf (LOG_LOG, "connection timed out");
93 void MyServer::failNotify()
95 logf (LOG_LOG, "connection closed by client");
99 int main(int argc, char **argv)
101 Yaz_SocketManager mySocketManager;
102 Yaz_PDU_Assoc *my_PDU_Assoc = new Yaz_PDU_Assoc(&mySocketManager, 0);
104 MyServer z(my_PDU_Assoc);
110 for (int i = 1; i < argc; i++)
113 while (!stop && mySocketManager.processEvent() > 0)