2 * Copyright (c) 1998-1999, Index Data.
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
6 * $Log: yaz-pdu-assoc.h,v $
7 * Revision 1.2 1999-01-28 13:08:40 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-socket-observer.h>
18 #include <yaz-pdu-observer.h>
20 /** Simple Protocol Data Unit Assocation.
21 This object sends - and receives PDU's using the COMSTACK
22 network utility. To use the association in client role, use
23 the method connect. The server role is initiated by using the
26 class Yaz_PDU_Assoc : public IYaz_PDU_Observable, IYazSocketObserver {
28 enum { Connecting, Connected, Listen, Ready, Closed } m_state;
31 PDU_Queue(const char *buf, int len);
32 PDU_Queue::~PDU_Queue();
37 Yaz_PDU_Assoc *m_parent;
38 Yaz_PDU_Assoc *m_children;
39 Yaz_PDU_Assoc *m_next;
40 COMSTACK Yaz_PDU_Assoc::comstack();
42 IYazSocketObservable *m_socketObservable;
43 IYaz_PDU_Observer *m_PDU_Observer;
46 PDU_Queue *m_queue_out;
47 int Yaz_PDU_Assoc::flush_PDU();
50 /// Create object using specified socketObservable
51 Yaz_PDU_Assoc(IYazSocketObservable *socketObservable, COMSTACK cs);
52 /// Close socket and destroy object.
53 virtual ~Yaz_PDU_Assoc();
55 IYaz_PDU_Observable *clone();
57 int send_PDU(const char *buf, int len);
58 /// connect to server (client role)
59 void connect(IYaz_PDU_Observer *observer, const char *addr);
60 /// listen for clients (server role)
61 void listen(IYaz_PDU_Observer *observer, const char *addr);
62 /// Socket notification
63 void socketNotify(int event);