2 * Copyright (c) 1998-2005, Index Data.
3 * See the file LICENSE for details.
5 * $Id: pdu-assoc.h,v 1.1 2006-03-29 13:14:15 adam Exp $
8 #ifndef YAZ_PDU_ASSOC_INCLUDED
9 #define YAZ_PDU_ASSOC_INCLUDED
11 #include <yaz/comstack.h>
12 #include <yazpp/socket-observer.h>
13 #include <yazpp/pdu-observer.h>
16 /** Simple Protocol Data Unit Assocation.
17 This object sends - and receives PDU's using the COMSTACK
18 network utility. To use the association in client role, use
19 the method connect. The server role is initiated by using the
22 class YAZ_EXPORT PDU_Assoc : public IPDU_Observable, yazpp_1::ISocketObserver {
23 friend class PDU_AssocThread;
35 PDU_Queue(const char *buf, int len);
42 PDU_Assoc *m_children;
45 yazpp_1::ISocketObservable *m_socketObservable;
46 IPDU_Observer *m_PDU_Observer;
49 PDU_Queue *m_queue_out;
50 PDU_Queue *m_queue_in;
55 void init(yazpp_1::ISocketObservable *socketObservable);
57 COMSTACK comstack(const char *type_and_host, void **vp);
58 /// Create object using specified socketObservable
59 PDU_Assoc(yazpp_1::ISocketObservable *socketObservable);
60 /// Create Object using existing comstack
61 PDU_Assoc(yazpp_1::ISocketObservable *socketObservable,
63 /// Close socket and destroy object.
64 /// virtual ~PDU_Assoc();
66 IPDU_Observable *clone();
68 int send_PDU(const char *buf, int len);
69 /// connect to server (client role)
70 int connect(IPDU_Observer *observer, const char *addr);
71 /// listen for clients (server role)
72 int listen(IPDU_Observer *observer, const char *addr);
73 /// Socket notification
74 void socketNotify(int event);
80 void idleTime (int timeout);
82 virtual void childNotify(COMSTACK cs);
83 const char *getpeername();
86 class YAZ_EXPORT PDU_AssocThread : public PDU_Assoc {
88 PDU_AssocThread(yazpp_1::ISocketObservable *socketObservable);
90 void childNotify(COMSTACK cs);
100 * indent-tabs-mode: nil
102 * vim: shiftwidth=4 tabstop=8 expandtab