2 * Copyright (c) 1998-1999, Index Data.
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
6 * $Log: yaz-client.cpp,v $
7 * Revision 1.2 1999-01-28 13:08:42 adam
8 * Yaz_PDU_Assoc better encapsulated. Memory leak fix in
9 * yaz-socket-manager.cc.
11 * Revision 1.1.1.1 1999/01/28 09:41:07 adam
12 * First implementation of YAZ++.
17 #include <yaz-ir-assoc.h>
18 #include <yaz-pdu-assoc.h>
19 #include <yaz-socket-manager.h>
21 class MyClient : public Yaz_IR_Assoc {
23 MyClient(IYaz_PDU_Observable *the_PDU_Observable);
24 void recv_Z_PDU(Z_APDU *apdu);
25 IYaz_PDU_Observer *clone(IYaz_PDU_Observable *the_PDU_Observable);
29 void MyClient::recv_Z_PDU(Z_APDU *apdu)
31 logf (LOG_LOG, "recv_APDU");
34 case Z_APDU_initResponse:
35 logf (LOG_LOG, "got InitResponse");
37 case Z_APDU_searchResponse:
38 logf (LOG_LOG, "got searchResponse");
43 IYaz_PDU_Observer *MyClient::clone(IYaz_PDU_Observable *the_PDU_Observable)
45 return new MyClient(the_PDU_Observable);
48 MyClient::MyClient(IYaz_PDU_Observable *the_PDU_Observable) :
49 Yaz_IR_Assoc (the_PDU_Observable)
54 void MyClient::sendInit()
56 Z_APDU *apdu = create_Z_PDU(Z_APDU_initRequest);
57 Z_InitRequest *req = apdu->u.initRequest;
59 ODR_MASK_SET(req->options, Z_Options_search);
60 ODR_MASK_SET(req->options, Z_Options_present);
61 ODR_MASK_SET(req->options, Z_Options_namedResultSets);
62 ODR_MASK_SET(req->options, Z_Options_triggerResourceCtrl);
63 ODR_MASK_SET(req->options, Z_Options_scan);
64 ODR_MASK_SET(req->options, Z_Options_sort);
65 ODR_MASK_SET(req->options, Z_Options_extendedServices);
66 ODR_MASK_SET(req->options, Z_Options_delSet);
68 ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_1);
69 ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_2);
70 ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_3);
75 int main(int argc, char **argv)
77 Yaz_SocketManager mySocketManager;
79 MyClient z(new Yaz_PDU_Assoc(&mySocketManager, 0));
81 z.client("localhost:9999");
84 while (mySocketManager.processEvent() > 0)