2 * Copyright (c) 1998-2005, Index Data.
3 * See the file LICENSE for details.
5 * $Id: pdu-observer.h,v 1.2 2008-01-21 15:57:27 adam Exp $
8 #ifndef YAZ_PDU_OBSERVER_H
9 #define YAZ_PDU_OBSERVER_H
11 #include <yaz/yconfig.h>
17 /** Protocol Data Unit Observable.
18 This interface implements a Protocol Data Unit (PDU) network driver.
19 The PDU's is not encoded/decoded by this interface. They are simply
20 transmitted/received over the network. To use this interface the
21 IPDU_Observer interface must be implemented.
23 class YAZ_EXPORT IPDU_Observable {
25 /// Send encoded PDU buffer of specified length
26 virtual int send_PDU(const char *buf, int len) = 0;
27 /// Connect with server specified by addr.
28 virtual int connect(IPDU_Observer *observer, const char *addr) = 0;
29 /// Listen on address addr.
30 virtual int listen(IPDU_Observer *observer, const char *addr) = 0;
32 virtual void shutdown() = 0;
33 /// Make clone of this object using this interface
34 virtual IPDU_Observable *clone() = 0;
35 /// Destroy completely
36 virtual void destroy() = 0;
38 virtual void idleTime (int timeout) = 0;
40 virtual const char *getpeername() = 0;
42 virtual void close_session() = 0;
44 virtual ~IPDU_Observable();
47 /** Protocol Data Unit Observer.
48 This interface is used together with the IPDU_Observable interface
49 and acts as a callback interface for it.
51 class YAZ_EXPORT IPDU_Observer {
53 /// A PDU has been received
54 virtual void recv_PDU(const char *buf, int len) = 0;
55 /// Called when Iyaz_PDU_Observable::connect was successful.
56 virtual void connectNotify() = 0;
57 /// Called whenever the connection was closed
58 virtual void failNotify() = 0;
59 /// Called whenever there is a timeout
60 virtual void timeoutNotify() = 0;
61 /// Make clone of observer using IPDU_Observable interface
62 virtual IPDU_Observer *sessionNotify(
63 IPDU_Observable *the_PDU_Observable, int fd) = 0;
65 virtual ~IPDU_Observer();
73 * indent-tabs-mode: nil
75 * vim: shiftwidth=4 tabstop=8 expandtab