2 * Copyright (c) 1998-1999, Index Data.
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
6 * $Id: yaz-pdu-assoc.h,v 1.7 1999-12-06 13:52:45 adam Exp $
9 #include <yaz/comstack.h>
10 #include <yaz-socket-observer.h>
11 #include <yaz-pdu-observer.h>
13 /** Simple Protocol Data Unit Assocation.
14 This object sends - and receives PDU's using the COMSTACK
15 network utility. To use the association in client role, use
16 the method connect. The server role is initiated by using the
19 class YAZ_EXPORT Yaz_PDU_Assoc : public IYaz_PDU_Observable, IYazSocketObserver {
21 enum { Connecting, Listen, Ready, Closed } m_state;
24 PDU_Queue(const char *buf, int len);
25 PDU_Queue::~PDU_Queue();
30 Yaz_PDU_Assoc *m_parent;
31 Yaz_PDU_Assoc *m_children;
32 Yaz_PDU_Assoc *m_next;
33 COMSTACK Yaz_PDU_Assoc::comstack();
35 IYazSocketObservable *m_socketObservable;
36 IYaz_PDU_Observer *m_PDU_Observer;
39 PDU_Queue *m_queue_out;
40 int Yaz_PDU_Assoc::flush_PDU();
45 /// Create object using specified socketObservable
46 Yaz_PDU_Assoc(IYazSocketObservable *socketObservable);
47 /// Close socket and destroy object.
48 virtual ~Yaz_PDU_Assoc();
50 IYaz_PDU_Observable *clone();
52 int send_PDU(const char *buf, int len);
53 /// connect to server (client role)
54 void connect(IYaz_PDU_Observer *observer, const char *addr);
55 /// listen for clients (server role)
56 void listen(IYaz_PDU_Observer *observer, const char *addr);
57 /// open with existing socket
58 void socket(IYaz_PDU_Observer *observer, int fd);
59 /// Socket notification
60 void socketNotify(int event);
66 void idleTime (int timeout);
68 virtual void childNotify(int fd);