2 * Copyright (c) 1998-2000, Index Data.
3 * See the file LICENSE for details.
5 * $Id: yaz-pdu-assoc.h,v 1.11 2000-09-12 16:40:33 heikki Exp $
8 #ifndef YAZ_PDU_ASSOC_INCLUDED
9 #define YAZ_PDU_ASSOC_INCLUDED
11 #include <yaz/comstack.h>
12 #include <yaz-socket-observer.h>
13 #include <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 {
23 enum { Connecting, Listen, Ready, Closed } m_state;
26 PDU_Queue(const char *buf, int len);
27 PDU_Queue::~PDU_Queue();
32 Yaz_PDU_Assoc *m_parent;
33 Yaz_PDU_Assoc *m_children;
34 Yaz_PDU_Assoc *m_next;
36 IYazSocketObservable *m_socketObservable;
37 IYaz_PDU_Observer *m_PDU_Observer;
40 PDU_Queue *m_queue_out;
41 int Yaz_PDU_Assoc::flush_PDU();
47 /// Create object using specified socketObservable
48 Yaz_PDU_Assoc(IYazSocketObservable *socketObservable);
49 /// Close socket and destroy object.
50 /// virtual ~Yaz_PDU_Assoc();
52 IYaz_PDU_Observable *clone();
54 int send_PDU(const char *buf, int len);
55 /// connect to server (client role)
56 void connect(IYaz_PDU_Observer *observer, const char *addr);
57 /// listen for clients (server role)
58 void listen(IYaz_PDU_Observer *observer, const char *addr);
59 /// open with existing socket
60 void socket(IYaz_PDU_Observer *observer, int fd);
61 /// Socket notification
62 void socketNotify(int event);
68 void idleTime (int timeout);
70 virtual void childNotify(int fd);