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.5 1999-04-09 11:46:57 adam
8 * Added object Yaz_Z_Assoc. Much more functional client.
10 * Revision 1.4 1999/03/23 14:17:57 adam
11 * More work on timeout handling. Work on yaz-client.
13 * Revision 1.3 1999/02/02 14:01:22 adam
14 * First WIN32 port of YAZ++.
16 * Revision 1.2 1999/01/28 13:08:47 adam
17 * Yaz_PDU_Assoc better encapsulated. Memory leak fix in
18 * yaz-socket-manager.cc.
20 * Revision 1.1.1.1 1999/01/28 09:41:07 adam
21 * First implementation of YAZ++.
26 #include <yaz-z-assoc.h>
27 #include <yaz-pdu-assoc.h>
28 #include <yaz-socket-manager.h>
30 class MyServer : public Yaz_Z_Assoc {
32 MyServer(IYaz_PDU_Observable *the_PDU_Observable);
33 void recv_Z_PDU(Z_APDU *apdu);
34 IYaz_PDU_Observer* clone(IYaz_PDU_Observable *the_PDU_Observable);
43 void MyServer::recv_Z_PDU(Z_APDU *apdu)
45 logf (LOG_LOG, "recv_Z_PDU");
48 case Z_APDU_initRequest:
49 logf (LOG_LOG, "got InitRequest");
50 apdu = create_Z_PDU(Z_APDU_initResponse);
53 case Z_APDU_searchRequest:
54 logf (LOG_LOG, "got searchRequest");
55 apdu = create_Z_PDU(Z_APDU_searchResponse);
58 case Z_APDU_presentRequest:
59 logf (LOG_LOG, "got presentRequest");
60 apdu = create_Z_PDU(Z_APDU_presentResponse);
67 IYaz_PDU_Observer *MyServer::clone(IYaz_PDU_Observable *the_PDU_Observable)
69 logf (LOG_LOG, "child no %d", m_no);
71 return new MyServer(the_PDU_Observable);
74 MyServer::MyServer(IYaz_PDU_Observable *the_PDU_Observable) :
75 Yaz_Z_Assoc (the_PDU_Observable)
80 void MyServer::timeoutNotify()
82 logf (LOG_LOG, "connection timed out");
86 void MyServer::failNotify()
88 logf (LOG_LOG, "connection closed by client");
92 int main(int argc, char **argv)
94 Yaz_SocketManager mySocketManager;
95 Yaz_PDU_Assoc *my_PDU_Assoc = new Yaz_PDU_Assoc(&mySocketManager, 0);
97 my_PDU_Assoc->idleTime(20);
98 MyServer z(my_PDU_Assoc);
104 for (int i = 1; i < argc; i++)
107 while (!stop && mySocketManager.processEvent() > 0)