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.4 1999-03-23 14:17:57 adam
8 * More work on timeout handling. Work on yaz-client.
10 * Revision 1.3 1999/02/02 14:01:22 adam
11 * First WIN32 port of YAZ++.
13 * Revision 1.2 1999/01/28 13:08:47 adam
14 * Yaz_PDU_Assoc better encapsulated. Memory leak fix in
15 * yaz-socket-manager.cc.
17 * Revision 1.1.1.1 1999/01/28 09:41:07 adam
18 * First implementation of YAZ++.
23 #include <yaz-ir-assoc.h>
24 #include <yaz-pdu-assoc.h>
25 #include <yaz-socket-manager.h>
27 class MyServer : public Yaz_IR_Assoc {
29 MyServer(IYaz_PDU_Observable *the_PDU_Observable);
30 void recv_Z_PDU(Z_APDU *apdu);
31 IYaz_PDU_Observer* clone(IYaz_PDU_Observable *the_PDU_Observable);
40 void MyServer::recv_Z_PDU(Z_APDU *apdu)
42 logf (LOG_LOG, "recv_Z_PDU");
45 case Z_APDU_initRequest:
46 logf (LOG_LOG, "got InitRequest");
47 apdu = create_Z_PDU(Z_APDU_initResponse);
50 case Z_APDU_searchRequest:
51 logf (LOG_LOG, "got searchRequest");
52 apdu = create_Z_PDU(Z_APDU_searchResponse);
55 case Z_APDU_presentRequest:
56 logf (LOG_LOG, "got presentRequest");
57 apdu = create_Z_PDU(Z_APDU_presentResponse);
64 IYaz_PDU_Observer *MyServer::clone(IYaz_PDU_Observable *the_PDU_Observable)
66 logf (LOG_LOG, "child no %d", m_no);
68 return new MyServer(the_PDU_Observable);
71 MyServer::MyServer(IYaz_PDU_Observable *the_PDU_Observable) :
72 Yaz_IR_Assoc (the_PDU_Observable)
77 void MyServer::timeoutNotify()
79 logf (LOG_LOG, "connection timed out");
83 void MyServer::failNotify()
85 logf (LOG_LOG, "connection closed by client");
89 int main(int argc, char **argv)
91 Yaz_SocketManager mySocketManager;
92 Yaz_PDU_Assoc *my_PDU_Assoc = new Yaz_PDU_Assoc(&mySocketManager, 0);
94 my_PDU_Assoc->idleTime(20);
95 MyServer z(my_PDU_Assoc);
101 for (int i = 1; i < argc; i++)
104 while (!stop && mySocketManager.processEvent() > 0)