2 * Copyright (c) 1998-2000, Index Data.
3 * See the file LICENSE for details.
5 * $Id: yaz-pdu-assoc.h,v 1.2 2001-03-26 14:43:49 adam Exp $
8 #ifndef YAZ_PDU_ASSOC_INCLUDED
9 #define YAZ_PDU_ASSOC_INCLUDED
11 #include <yaz/comstack.h>
12 #include <yaz++/yaz-socket-observer.h>
13 #include <yaz++/yaz-pdu-observer.h>
15 /** Simple Protocol Data Unit Assocation.
16 This object sends - and receives PDU's using the COMSTACK
17 network utility. To use the association in client role, use
18 the method connect. The server role is initiated by using the
21 class YAZ_EXPORT Yaz_PDU_Assoc : public IYaz_PDU_Observable, IYazSocketObserver {
22 friend class Yaz_PDU_AssocThread;
34 PDU_Queue(const char *buf, int len);
35 PDU_Queue::~PDU_Queue();
40 Yaz_PDU_Assoc *m_parent;
41 Yaz_PDU_Assoc *m_children;
42 Yaz_PDU_Assoc *m_next;
44 IYazSocketObservable *m_socketObservable;
45 IYaz_PDU_Observer *m_PDU_Observer;
48 PDU_Queue *m_queue_out;
49 int Yaz_PDU_Assoc::flush_PDU();
53 void init(IYazSocketObservable *socketObservable);
55 COMSTACK comstack(const char *type_and_host, void **vp);
56 /// Create object using specified socketObservable
57 Yaz_PDU_Assoc(IYazSocketObservable *socketObservable);
58 /// Create Object using existing comstack
59 Yaz_PDU_Assoc(IYazSocketObservable *socketObservable,
61 /// Close socket and destroy object.
62 /// virtual ~Yaz_PDU_Assoc();
64 IYaz_PDU_Observable *clone();
66 int send_PDU(const char *buf, int len);
67 /// connect to server (client role)
68 void connect(IYaz_PDU_Observer *observer, const char *addr);
69 /// listen for clients (server role)
70 void listen(IYaz_PDU_Observer *observer, const char *addr);
71 /// Socket notification
72 void socketNotify(int event);
78 void idleTime (int timeout);
80 virtual void childNotify(COMSTACK cs);
83 class YAZ_EXPORT Yaz_PDU_AssocThread : public Yaz_PDU_Assoc {
85 Yaz_PDU_AssocThread(IYazSocketObservable *socketObservable);
87 void childNotify(COMSTACK cs);