11 #include "iwvlistener.h"
12 #include "wvstreamclone.h"
21 IWvListenerCallback acceptor;
22 IWvListenerWrapper wrapper;
27 virtual void addwrap(IWvListenerWrapper _wrapper);
29 virtual IWvListenerCallback
onaccept(IWvListenerCallback _cb);
31 void runonce(time_t msec_delay);
37 {
if (cloned) cloned->close(); }
41 virtual void callback();
45 virtual int getrfd()
const
46 {
return cloned ? cloned->getrfd() : -1; }
47 virtual int getwfd()
const
48 {
return cloned ? cloned->getwfd() : -1; }
50 virtual const WvAddr *src()
const
51 {
return cloned ? cloned->src() : NULL; }
53 virtual void pre_select(SelectInfo &si)
54 {
if (cloned) cloned->pre_select(si); }
55 virtual bool post_select(SelectInfo &si)
56 {
return cloned ? cloned->post_select(si) :
false; }
58 virtual size_t read(
void *buf,
size_t count)
60 virtual size_t write(
const void *buf,
size_t count)
62 virtual size_t read(
WvBuf &outbuf,
size_t count)
64 virtual size_t write(
WvBuf &inbuf,
size_t count = INT_MAX)
76 virtual bool flush(time_t msec_timeout)
88 virtual const char *wsname()
const
89 {
return "Listener"; }
90 virtual void set_wsname(WvStringParm name)
92 void set_wsname(WVSTRING_FORMAT_DECL)
93 { set_wsname(
WvString(WVSTRING_FORMAT_CALL)); }
94 virtual const char *wstype()
const
95 {
return "Listener"; }
96 virtual WSID wsid()
const
100 virtual WvString getattr(WvStringParm name)
const;
121 virtual const WvAddr *src()
const;
124 #endif // __WVLISTENER_H
virtual IWvStreamCallback setclosecallback(IWvStreamCallback _cb)
Sets a callback to be invoked on close().
virtual bool isreadable()
Returns true if the stream is readable.
virtual bool isok() const
By default, returns true if geterr() == 0.
virtual IWvStreamCallback setexceptcallback(IWvStreamCallback _cb)
Sets a callback to be invoked when the stream is in exception state.
virtual void maybe_autoclose()
Auto-close the stream if the time is right.
virtual IWvListenerCallback onaccept(IWvListenerCallback _cb)
Set a user-defined function to be called when a new connection is available.
virtual IWvStream * accept()
Accept a connection from this stream.
WvString is an implementation of a simple and efficient printable-string class.
virtual IWvStreamCallback setreadcallback(IWvStreamCallback _cb)
Sets a callback to be invoked when the stream is readable.
virtual bool flush(time_t msec_timeout)
flush the output buffer, if we can do it without delaying more than msec_timeout milliseconds at a ti...
virtual IWvStreamCallback setwritecallback(IWvStreamCallback _cb)
Sets a callback to be invoked when the stream is writable.
Base class for different address types, each of which will have the ability to convert itself to/from...
Specialization of WvBufBase for unsigned char type buffers intended for use with raw memory buffers.
This is a listener that doesn't work.
virtual bool iswritable()
Returns true if the stream is writable (without using the outbuf).
virtual bool isok() const =0
By default, returns true if geterr() == 0.
virtual bool should_flush()
Returns true if we want to flush the output buffer right now.
virtual void noread()
Shuts down the reading side of the stream.
virtual void nowrite()
Shuts down the writing side of the stream.
virtual bool isok() const
By default, returns true if geterr() == 0.
virtual void addwrap(IWvListenerWrapper _wrapper)
Add a wrapper function for this stream: something that accept() will call to possibly wrap the stream...
virtual void outbuf_limit(size_t size)
set the maximum size of outbuf, beyond which a call to write() will return 0.
virtual bool isok() const
By default, returns true if geterr() == 0.