WvUnixListener Class Reference

#include <wvunixlistener.h>

Inheritance diagram for WvUnixListener:

Inheritance graph
[legend]

List of all members.


Detailed Description

Server end of a Unix Sockets stream.

Definition at line 15 of file wvunixlistener.h.


Public Member Functions

 WvUnixListener (const WvUnixAddr &_addr, int create_mode)
virtual void close ()
IWvStream * accept ()
 return a new WvUnixConn socket corresponding to a newly-accepted connection.
void auto_accept (WvIStreamList *list, wv::function< void(IWvStream *)> cb)
 Tell this listener to automatically accept new connections, assigning them their own callback function 'cb' Pass list==NULL or run setcallback() to disable auto-accepting.
void auto_accept (wv::function< void(IWvStream *)> cb)
 Like auto_accept() above, but always uses the globallist instead of a user-defined list.
virtual const WvUnixAddrsrc () const
 src() is a bit of a misnomer, but it returns the socket address.
const char * wstype () const
virtual void addwrap (IWvListenerWrapper _wrapper)
virtual IWvListenerCallback onaccept (IWvListenerCallback _cb)
IWvStream * wrap (IWvStream *s)
void runonce (time_t msec_delay)
virtual bool isok () const
virtual void callback ()
int getfd () const
virtual int getrfd () const
virtual int getwfd () const
virtual void pre_select (SelectInfo &si)
virtual bool post_select (SelectInfo &si)
virtual size_t read (void *buf, size_t count)
virtual size_t read (WvBuf &outbuf, size_t count)
virtual size_t write (const void *buf, size_t count)
virtual size_t write (WvBuf &inbuf, size_t count=INT_MAX)
virtual void noread ()
virtual void nowrite ()
virtual void maybe_autoclose ()
virtual bool isreadable ()
virtual bool iswritable ()
virtual bool flush (time_t msec_timeout)
virtual bool should_flush ()
virtual IWvStreamCallback setreadcallback (IWvStreamCallback _cb)
virtual IWvStreamCallback setwritecallback (IWvStreamCallback _cb)
virtual IWvStreamCallback setexceptcallback (IWvStreamCallback _cb)
virtual IWvStreamCallback setclosecallback (IWvStreamCallback _cb)
virtual const char * wsname () const
virtual void set_wsname (WvStringParm name)
void set_wsname (WVSTRING_FORMAT_DECL)
virtual WSID wsid () const
virtual void outbuf_limit (size_t size)
virtual WvString getattr (WvStringParm name) const
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.
virtual WvString errstr () const
virtual void seterr (int _errnum)
 Set the errnum variable -- we have an error.
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.
virtual unsigned int release ()=0
 Indicate that you are finished using this object.
virtual IObjectgetInterface (const UUID &)=0
 Returns the requested XPLC interface.
virtual IWeakRefgetWeakRef ()=0
 Return a weak reference to this object.

Static Public Member Functions

static IWvListener * create (WvString moniker, IObject *obj=NULL)
static IWvStream * create (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).

Public Attributes

IWvStream * cloned
IWvListenerCallback acceptor
IWvListenerWrapper wrapper

Protected Member Functions

void accept_callback (WvIStreamList *list, wv::function< void(IWvStream *)> cb, IWvStream *_connection)

Protected Attributes

WvUnixAddr addr
bool bound_okay
int errnum
WvString errstring

Member Function Documentation

IWvStream * WvUnixListener::accept (  ) 

return a new WvUnixConn socket corresponding to a newly-accepted connection.

If no connection is ready immediately, we wait for one indefinitely. You can use select(read=true) to check for a waiting connection.

Definition at line 214 of file wvunixsocket.cc.

References WvErrorBase::isok(), and WvErrorBase::seterr().

void WvUnixListener::auto_accept ( WvIStreamList list,
wv::function< void(IWvStream *)>  cb 
)

Tell this listener to automatically accept new connections, assigning them their own callback function 'cb' Pass list==NULL or run setcallback() to disable auto-accepting.

Be careful not to accept() connections yourself if you do this, or we may end up accept()ing twice, causing a hang the second time.

Definition at line 234 of file wvunixsocket.cc.

Referenced by auto_accept().

const WvUnixAddr * WvUnixListener::src (  )  const [virtual]

src() is a bit of a misnomer, but it returns the socket address.

Definition at line 257 of file wvunixsocket.cc.

virtual int WvErrorBase::geterr (  )  const [inline, virtual, inherited]

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.

Definition at line 48 of file wverror.h.

Referenced by UniIniGen::commit(), UniFileSystemGen::get(), WvStreamClone::geterr(), UniIniGen::refresh(), WvStream::seterr(), and WvMagicCircle::WvMagicCircle().

void WvErrorBase::seterr ( int  _errnum  )  [virtual, inherited]

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 accept(), WvTCPListener::accept(), WvDSAKey::getpem(), WvGlob::set(), WvStream::seterr(), WvMagicCircle::WvMagicCircle(), WvShmZone::WvShmZone(), and WvTCPListener::WvTCPListener().

void WvErrorBase::noerr (  )  [inline, inherited]

Reset our error state - there's no error condition anymore.

Definition at line 78 of file wverror.h.

virtual unsigned int IObject::addRef (  )  [pure virtual, inherited]

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 IObjectImplInternal::getInterface(), and WeakRef::getObject().

virtual unsigned int IObject::release (  )  [pure virtual, inherited]

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 mutate().

virtual IObject* IObject::getInterface ( const UUID  )  [pure virtual, inherited]

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 mutate().

virtual IWeakRef* IObject::getWeakRef (  )  [pure virtual, inherited]

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:

Generated on Wed May 13 02:03:22 2009 for WvStreams by  doxygen 1.5.5