WvStreams
wvunixdgsocket.h
1 #ifndef __WVUNIXDGSOCKET_H
2 #define __WVUNIXDGSOCKET_H
3 
4 #include <sys/types.h>
5 #include <sys/syslog.h>
6 #include <sys/socket.h>
7 #include <sys/stat.h>
8 #include <fcntl.h>
9 
10 #include "wvlog.h"
11 #include "wvstring.h"
12 #include "wvlinklist.h"
13 #include "wvfdstream.h"
14 #include "wvaddr.h"
15 
16 class WvUnixDGListener;
17 class WvUnixDGConn;
18 
25 class WvUnixDGSocket : public WvFDStream {
26 
27  bool server;
28  int backoff;
29 
30  DeclareWvList(WvBuf);
31  WvBufList bufs;
32 
33 public:
34  WvUnixDGSocket(WvStringParm filename, bool _server, int perms = 0222);
35 
36  virtual ~WvUnixDGSocket();
37 
38  virtual size_t uwrite(const void *buf, size_t count);
39  virtual void pre_select(SelectInfo &si);
40  virtual bool post_select(SelectInfo &si);
41 
42 protected:
43  WvString socketfile;
44 
45 public:
46  const char *wstype() const { return "WvUnixDGSocket"; }
47 
48  size_t bufsize;
49 };
50 
58 {
59 public:
60  WvUnixDGConn(WvStringParm filename)
61  : WvUnixDGSocket(filename, false)
62  {}
63 
64 public:
65  const char *wstype() const { return "WvUnixDGConn"; }
66 };
67 
77 {
78 public:
79  WvUnixDGListener(WvStringParm filename, int perms = 0222)
80  : WvUnixDGSocket(filename, true, perms)
81  {}
82 
83 public:
84  const char *wstype() const { return "WvUnixDGListener"; }
85 };
86 
87 
88 
89 #endif
WvUnixDGListener
Server end of a Unix datagram socket stream.
Definition: wvunixdgsocket.h:76
WvUnixDGSocket::uwrite
virtual size_t uwrite(const void *buf, size_t count)
unbuffered I/O functions; these ignore the buffer, which is handled by write().
Definition: wvunixdgsocket.cc:76
WvString
WvString is an implementation of a simple and efficient printable-string class.
Definition: wvstring.h:329
WvUnixDGConn
WvStream-based Unix datagram domain socket connection class that listens on filename.
Definition: wvunixdgsocket.h:57
IWvStream::SelectInfo
the data structure used by pre_select()/post_select() and internally by select().
Definition: iwvstream.h:50
WvBufBase< unsigned char >
Specialization of WvBufBase for unsigned char type buffers intended for use with raw memory buffers.
Definition: wvbuf.h:22
WvUnixDGSocket::post_select
virtual bool post_select(SelectInfo &si)
post_select() is called after ::select(), and returns true if this object is now ready.
Definition: wvunixdgsocket.cc:114
WvUnixDGSocket::pre_select
virtual void pre_select(SelectInfo &si)
pre_select() sets up for eventually calling ::select().
Definition: wvunixdgsocket.cc:91
WvFdStream
Base class for streams built on Unix file descriptors.
Definition: wvfdstream.h:20
WvUnixDGSocket
WvStream-based Unix datagram domain socket base class.
Definition: wvunixdgsocket.h:25