WvStreams
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
IWvListener Class Referenceabstract
Inheritance diagram for IWvListener:
Inheritance graph
[legend]

Public Member Functions

virtual IWvStreamaccept ()=0
 Accept a connection from this stream. More...
 
virtual IWvListenerCallback onaccept (IWvListenerCallback _cb)=0
 Set a user-defined function to be called when a new connection is available. More...
 
virtual void addwrap (IWvListenerWrapper _wrapper)=0
 Add a wrapper function for this stream: something that accept() will call to possibly wrap the stream from accept() before returning it. More...
 
virtual void close ()=0
 
virtual bool isok () const =0
 By default, returns true if geterr() == 0. More...
 
virtual void callback ()=0
 
virtual int getrfd () const =0
 
virtual int getwfd () const =0
 
virtual const WvAddrsrc () const =0
 
virtual void pre_select (SelectInfo &si)=0
 
virtual bool post_select (SelectInfo &si)=0
 
virtual size_t read (void *buf, size_t count)=0
 
virtual size_t read (WvBuf &outbuf, size_t count)=0
 
virtual size_t write (const void *buf, size_t count)=0
 
virtual size_t write (WvBuf &inbuf, size_t count=INT_MAX)=0
 
virtual void noread ()=0
 Shuts down the reading side of the stream. More...
 
virtual void nowrite ()=0
 Shuts down the writing side of the stream. More...
 
virtual void maybe_autoclose ()=0
 Auto-close the stream if the time is right. More...
 
virtual bool isreadable ()=0
 Returns true if the stream is readable.
 
virtual bool iswritable ()=0
 Returns true if the stream is writable (without using the outbuf).
 
virtual bool flush (time_t msec_timeout)=0
 flush the output buffer, if we can do it without delaying more than msec_timeout milliseconds at a time. More...
 
virtual bool should_flush ()=0
 Returns true if we want to flush the output buffer right now. More...
 
virtual IWvStreamCallback setreadcallback (IWvStreamCallback _callfunc)=0
 Sets a callback to be invoked when the stream is readable.
 
virtual IWvStreamCallback setwritecallback (IWvStreamCallback _callfunc)=0
 Sets a callback to be invoked when the stream is writable.
 
virtual IWvStreamCallback setexceptcallback (IWvStreamCallback _callfunc)=0
 Sets a callback to be invoked when the stream is in exception state.
 
virtual IWvStreamCallback setclosecallback (IWvStreamCallback _callfunc)=0
 Sets a callback to be invoked on close(). More...
 
virtual const char * wsname () const =0
 
virtual void set_wsname (WvStringParm name)=0
 
virtual const char * wstype () const =0
 
virtual WSID wsid () const =0
 
virtual void outbuf_limit (size_t size)=0
 set the maximum size of outbuf, beyond which a call to write() will return 0. More...
 
virtual WvString getattr (WvStringParm name) const =0
 
virtual int geterr () const
 If isok() is false, return the system error number corresponding to the error, -1 for a special error string (which you can obtain with errstr()) or 0 on end of file. More...
 
virtual WvString errstr () const
 
virtual void seterr (int _errnum)
 Set the errnum variable – we have an error. More...
 
void seterr (WvStringParm specialerr)
 
void seterr (WVSTRING_FORMAT_DECL)
 
void seterr (const WvErrorBase &err)
 
void seterr_both (int _errnum, WvStringParm specialerr)
 
void seterr_both (int _errnum, WVSTRING_FORMAT_DECL)
 
void noerr ()
 Reset our error state - there's no error condition anymore.
 
virtual unsigned int addRef ()=0
 Indicate you are using this object. More...
 
virtual unsigned int release ()=0
 Indicate that you are finished using this object. More...
 
virtual IObjectgetInterface (const UUID &)=0
 Returns the requested XPLC interface. More...
 
virtual IWeakRefgetWeakRef ()=0
 Return a weak reference to this object. More...
 

Static Public Member Functions

static IWvListenercreate (WvString moniker, IObject *obj=NULL)
 
static IWvStreamcreate (WvStringParm moniker, IObject *obj=NULL)
 
static WvString strerror (int errnum)
 A replacement for the operating system ::strerror() function that can map more kinds of error strings (especially in win32).
 

Protected Attributes

int errnum
 
WvString errstring
 

Detailed Description

Definition at line 16 of file iwvlistener.h.

Member Function Documentation

◆ accept()

virtual IWvStream* IWvListener::accept ( )
pure virtual

Accept a connection from this stream.

If none are available right now, might return NULL or block. (NULL is preferable.)

Implemented in WvNullListener, WvTCPListener, and WvUnixListener.

◆ onaccept()

virtual IWvListenerCallback IWvListener::onaccept ( IWvListenerCallback  _cb)
pure virtual

Set a user-defined function to be called when a new connection is available.

The new connection IWvStream is given, and it's the callback's responsibility to make sure it gets freed properly.

Implemented in WvListener.

Referenced by UniConfDaemon::listen(), and WvDBusServer::listen().

◆ addwrap()

virtual void IWvListener::addwrap ( IWvListenerWrapper  _wrapper)
pure virtual

Add a wrapper function for this stream: something that accept() will call to possibly wrap the stream from accept() before returning it.

You can use this more than once; the wrappers will be called in order (so the "innermost" stream is the original, the first wrapper is next, and so on).

Implemented in WvListener.

◆ isok()

virtual bool IWvStream::isok ( ) const
pure virtualinherited

◆ noread()

virtual void IWvStream::noread ( )
pure virtualinherited

Shuts down the reading side of the stream.

This is the opposite of nowrite(), but the name is actually slightly misleading; subsequent calls to read() might not fail; rather, if the other end of the connection tries to write to us, they should fail.

After noread(), if the read buffer (if any) is empty once, we promise that it will never refill.

If you call both noread() and nowrite(), then the stream does close() automatically once all buffers are empty.

Implemented in WvStream, WvStreamClone, WvListener, and WvSSLStream.

Referenced by WvStreamClone::noread().

◆ nowrite()

virtual void IWvStream::nowrite ( )
pure virtualinherited

Shuts down the writing side of the stream.

Subsequent calls to write() will fail. But if there's data in the output buffer, it will still be flushed.

If you call both noread() and nowrite(), then the stream does close() automatically once all buffers are empty.

Implemented in WvStream, WvStreamClone, WvListener, and WvSSLStream.

Referenced by WvStreamClone::flush_internal(), and WvStreamClone::nowrite().

◆ maybe_autoclose()

virtual void IWvStream::maybe_autoclose ( )
pure virtualinherited

Auto-close the stream if the time is right.

If noread() and nowrite() and all buffers are empty, then we can probably close.

Implemented in WvStream, WvFdStream, and WvListener.

◆ flush()

virtual bool IWvStream::flush ( time_t  msec_timeout)
pure virtualinherited

flush the output buffer, if we can do it without delaying more than msec_timeout milliseconds at a time.

(-1 means wait forever)

Returns true if it finished flushing (ie. the outbuf is empty).

FIXME: Something like this probably belongs in IWvStream, but probably not exactly this.

Implemented in WvStream, and WvListener.

Referenced by WvStreamClone::flush_internal().

◆ should_flush()

virtual bool IWvStream::should_flush ( )
pure virtualinherited

Returns true if we want to flush the output buffer right now.

This allows us to implement delayed_flush(), flush_then_close(), etc, but it's still super-ugly and probably needs to go away. (In fact, all our buffer flushing is super-ugly right now.)

Implemented in WvStream, and WvListener.

Referenced by WvStreamClone::post_select().

◆ setclosecallback()

virtual IWvStreamCallback IWvStream::setclosecallback ( IWvStreamCallback  _callfunc)
pure virtualinherited

Sets a callback to be invoked on close().


Implemented in WvListener, and WvStream.

Referenced by WvStreamsDaemon::add_die_stream(), WvStreamsDaemon::add_restart_stream(), WvStreamClone::close(), and WvStreamClone::setclone().

◆ outbuf_limit()

virtual void IWvStream::outbuf_limit ( size_t  size)
pure virtualinherited

set the maximum size of outbuf, beyond which a call to write() will return 0.


Implemented in WvStream, and WvListener.

◆ geterr()

virtual int WvErrorBase::geterr ( ) const
inlinevirtualinherited

If isok() is false, return the system error number corresponding to the error, -1 for a special error string (which you can obtain with errstr()) or 0 on end of file.

If isok() is true, returns an undefined number.

Reimplemented in WvStreamClone, and WvDBusServer.

Definition at line 48 of file wverror.h.

Referenced by UniIniGen::commit(), UniFileSystemGen::get(), WvDBusServer::geterr(), WvStreamClone::geterr(), WvEncoderStream::isok(), UniConfDaemon::listen(), WvStream::seterr(), and WvMagicCircle::WvMagicCircle().

◆ seterr()

void WvErrorBase::seterr ( int  _errnum)
virtualinherited

Set the errnum variable – we have an error.

If called more than once, seterr() doesn't change the error code away from the previous one. That way, we remember the original cause of our problems.

Subclasses may want to override seterr(int) to shut themselves down (eg. WvStream::close()) when an error condition is set.

Note that seterr(WvString) will call seterr(-1).

Reimplemented in WvStream.

Definition at line 144 of file wverror.cc.

Referenced by WvUnixListener::accept(), WvTCPListener::accept(), WvDSAKey::getpem(), WvGlob::set(), WvStream::seterr(), WvMagicCircle::WvMagicCircle(), WvPam::WvPam(), WvShmZone::WvShmZone(), and WvTCPListener::WvTCPListener().

◆ addRef()

virtual unsigned int IObject::addRef ( )
pure virtualinherited

Indicate you are using this object.

This increases the reference count of the object by one. Usually, when the reference count reaches zero, the object is freed automatically.

This called a "strong reference", because they will prevent the object from being destroyed. They should thus be used carefully, as they control the lifetime of the object. For example, you do not need to call addRef() on object passed as parameters, unless you intend on keeping them.

addRef() is often called automatically for you in XPLC, but you'll have to call release() by hand sometimes unless you use xplc_ptr.

Referenced by WvIStreamList::execute(), IObjectImplInternal::getInterface(), StaticServiceHandler::getObject(), WeakRef::getObject(), WvIStreamList::post_select(), WvQtStreamClone::WvQtStreamClone(), and WvSSLStream::WvSSLStream().

◆ release()

virtual unsigned int IObject::release ( )
pure virtualinherited

Indicate that you are finished using this object.

This decreases the reference count of the object by one. Usually, when the reference count reaches zero, the object is freed automatically.

You will usually need to manually release() any object given to you by any other XPLC function, unless you give the object to someone else who will call release.

If you use xplc_ptr, it will do this for you.

Referenced by WvIStreamList::execute(), mutate(), NewMoniker::resolve(), and MonikerService::resolve().

◆ getInterface()

virtual IObject* IObject::getInterface ( const UUID )
pure virtualinherited

Returns the requested XPLC interface.

Will return NULL if the interface is not supported. The returned interface has been addRef()ed, so you will need to release() it when done. Note that the interface returned may be a pointer to the same object or a different one - that's none of your business. Asking for the IObject interface should always return the same pointer for a given logical object, so this can be used for comparison by identity.

You should probably use the convenient mutate() and get() functions instead of this, or use an xplc_ptr, which mutates the object for you.

Referenced by get(), and mutate().

◆ getWeakRef()

virtual IWeakRef* IObject::getWeakRef ( )
pure virtualinherited

Return a weak reference to this object.

A weak reference points at the object, but does not control the lifetime of the object. An object can thus still be deleted while someone holds a weak reference. You will still need to release() the weak reference when you are done with it.

See also
IWeakRef

The documentation for this class was generated from the following files: