Fixed serious bug regarding timeouts. Improved logging for proxy.
[yazpp-moved-to-github.git] / include / yaz-socket-observer.h
1 /*
2  * Copyright (c) 1998-1999, Index Data.
3  * See the file LICENSE for details.
4  * Sebastian Hammer, Adam Dickmeiss
5  * 
6  * $Id: yaz-socket-observer.h,v 1.4 1999-04-20 10:30:05 adam Exp $
7  */
8
9 #ifndef YAZ_SOCKET_OBSERVER_H
10 #define YAZ_SOCKET_OBSERVER_H
11
12 #define YAZ_SOCKET_OBSERVE_READ 1
13 #define YAZ_SOCKET_OBSERVE_WRITE 2
14 #define YAZ_SOCKET_OBSERVE_EXCEPT 4
15 #define YAZ_SOCKET_OBSERVE_TIMEOUT 8
16
17 /**
18    Forward reference
19  */
20 class IYazSocketObserver;
21
22 /** Socket Observable.
23    This interface implements notification of socket events.
24    The module interested in (observing) the sockets
25    must implement the IYazSocketObserver interface. The
26    IYazSocketObserver only have to implement one function, so it's
27    quite simple to observe sockets change state.
28    The socket events below specifies read, write, exception,
29    and timeout respectively:
30    <pre>
31     YAZ_SOCKET_OBSERVE_READ
32     YAZ_SOCKET_OBSERVE_WRITE
33     YAZ_SOCKET_OBSERVE_EXCEPT
34     YAZ_SOCKET_OBSERVE_TIMEOUT
35     </pre>
36     The maskObserver method specifies which of these events the
37     observer is intertested in.
38 */
39 class YAZ_EXPORT IYazSocketObservable {
40  public:
41     /// Add an observer interested in socket fd
42     virtual void addObserver(int fd, IYazSocketObserver *observer) = 0;
43     /// Delete an observer
44     virtual void deleteObserver(IYazSocketObserver *observer) = 0;
45     /// Delete all observers
46     virtual void deleteObservers() = 0;
47     /// Specify the events that the observer is intersted in.
48     virtual void maskObserver(IYazSocketObserver *observer, int mask) = 0;
49     /// Specify timeout
50     virtual void timeoutObserver(IYazSocketObserver *observer,
51                                  unsigned timeout)=0;
52 };
53
54 /** Socket Observer.
55    The IYazSocketObserver interface implements a module interested
56    socket events. Look for objects that implements the
57    IYazSocketObservable interface!
58 */
59 class YAZ_EXPORT IYazSocketObserver {
60  public:
61     /// Notify the observer that something happened to socket
62     virtual void socketNotify(int event) = 0;
63 };
64
65 #endif