WvStreams
wvunixdgsocket.h
00001 #ifndef __WVUNIXDGSOCKET_H
00002 #define __WVUNIXDGSOCKET_H
00003 
00004 #include <sys/types.h>
00005 #include <sys/syslog.h>
00006 #include <sys/socket.h>
00007 #include <sys/stat.h>
00008 #include <fcntl.h>
00009 
00010 #include "wvlog.h"
00011 #include "wvstring.h"
00012 #include "wvlinklist.h"
00013 #include "wvfdstream.h"
00014 #include "wvaddr.h"
00015 
00016 class WvUnixDGListener;
00017 class WvUnixDGConn;
00018 
00025 class WvUnixDGSocket : public WvFDStream {
00026 
00027     bool server;
00028     int backoff;
00029 
00030     DeclareWvList(WvBuf);
00031     WvBufList bufs;
00032 
00033 public:
00034     WvUnixDGSocket(WvStringParm filename, bool _server, int perms = 0222);
00035 
00036     virtual  ~WvUnixDGSocket();
00037 
00038     virtual size_t uwrite(const void *buf, size_t count);
00039     virtual void pre_select(SelectInfo &si);
00040     virtual bool post_select(SelectInfo &si);
00041    
00042 protected:
00043      WvString socketfile;
00044      
00045 public:
00046     const char *wstype() const { return "WvUnixDGSocket"; }
00047 
00048     size_t bufsize;
00049 };
00050 
00057 class WvUnixDGConn : public WvUnixDGSocket
00058 {
00059 public:
00060     WvUnixDGConn(WvStringParm filename)
00061         : WvUnixDGSocket(filename, false)
00062         {}
00063         
00064 public:
00065     const char *wstype() const { return "WvUnixDGConn"; }
00066 };
00067 
00076 class WvUnixDGListener : public WvUnixDGSocket 
00077 { 
00078 public:
00079     WvUnixDGListener(WvStringParm filename, int perms = 0222)
00080         : WvUnixDGSocket(filename, true, perms)
00081         {}
00082 
00083 public:
00084     const char *wstype() const { return "WvUnixDGListener"; }
00085 };
00086 
00087 
00088 
00089 #endif