This class implements the
IYazSocketObservable interface and is a portable
socket wrapper around the select call.
This implementation is useful for daemons,
command line clients, etc.
#include <yaz++/socket-manager.h>
class Yaz_SocketManager : public IYazSocketObservable {
public:
// Add an observer
virtual void addObserver(int fd, IYazSocketObserver *observer);
// Delete an observer
virtual void deleteObserver(IYazSocketObserver *observer);
// Delete all observers
virtual void deleteObservers();
// Set event mask for observer
virtual void maskObserver(IYazSocketObserver *observer, int mask);
// Set timeout
virtual void timeoutObserver(IYazSocketObserver *observer,
unsigned timeout);
// Process one event. return > 0 if event could be processed;
int processEvent();
Yaz_SocketManager();
virtual ~Yaz_SocketManager();
};
This class implements the interfaces
IYaz_PDU_Observable
and
IYazSocketObserver.
This object implements a non-blocking client/server channel
that transmits BER encoded PDUs (or those offered by YAZ COMSTACK).
#include <yaz++/pdu-assoc.h>
class Yaz_PDU_Assoc : public IYaz_PDU_Observable,
IYazSocketObserver {
public:
COMSTACK comstack(const char *type_and_host, void **vp);
// Create object using specified socketObservable
Yaz_PDU_Assoc(IYazSocketObservable *socketObservable);
// Create Object using existing comstack
Yaz_PDU_Assoc(IYazSocketObservable *socketObservable,
COMSTACK cs);
// Close socket and destroy object.
virtual ~Yaz_PDU_Assoc();
// Clone the object
IYaz_PDU_Observable *clone();
// Send PDU
int send_PDU(const char *buf, int len);
// connect to server (client role)
void connect(IYaz_PDU_Observer *observer, const char *addr);
// listen for clients (server role)
void listen(IYaz_PDU_Observer *observer, const char *addr);
// Socket notification
void socketNotify(int event);
// Close socket
void close();
// Close and destroy
void destroy();
// Set Idle Time
void idleTime (int timeout);
// Child start...
virtual void childNotify(COMSTACK cs);
};