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.1 1999-01-28 09:41:07 adam
13 #include <yaz-ir-assoc.h>
14 #include <yaz-pdu-assoc.h>
15 #include <yaz-socket-manager.h>
17 class MyClient : public Yaz_IR_Assoc {
19 MyClient(IYaz_PDU_Observable *the_PDU_Observable);
20 void recv_Z_PDU(Z_APDU *apdu);
21 IYaz_PDU_Observer *clone(IYaz_PDU_Observable *the_PDU_Observable);
25 void MyClient::recv_Z_PDU(Z_APDU *apdu)
27 logf (LOG_LOG, "recv_APDU");
30 case Z_APDU_initResponse:
31 logf (LOG_LOG, "got InitResponse");
33 case Z_APDU_searchResponse:
34 logf (LOG_LOG, "got searchResponse");
39 IYaz_PDU_Observer *MyClient::clone(IYaz_PDU_Observable *the_PDU_Observable)
41 return new MyClient(the_PDU_Observable);
44 MyClient::MyClient(IYaz_PDU_Observable *the_PDU_Observable) :
45 Yaz_IR_Assoc (the_PDU_Observable)
50 void MyClient::sendInit()
52 Z_APDU *apdu = create_Z_PDU(Z_APDU_initRequest);
53 Z_InitRequest *req = apdu->u.initRequest;
55 ODR_MASK_SET(req->options, Z_Options_search);
56 ODR_MASK_SET(req->options, Z_Options_present);
57 ODR_MASK_SET(req->options, Z_Options_namedResultSets);
58 ODR_MASK_SET(req->options, Z_Options_triggerResourceCtrl);
59 ODR_MASK_SET(req->options, Z_Options_scan);
60 ODR_MASK_SET(req->options, Z_Options_sort);
61 ODR_MASK_SET(req->options, Z_Options_extendedServices);
62 ODR_MASK_SET(req->options, Z_Options_delSet);
64 ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_1);
65 ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_2);
66 ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_3);
71 int main(int argc, char **argv)
73 Yaz_SocketManager mySocketManager;
75 Yaz_PDU_Assoc my_PDU_Assoc(&mySocketManager, 0);
76 MyClient z(&my_PDU_Assoc);
78 z.client("localhost:9999");
81 while (mySocketManager.processEvent() > 0)