1 #include "wvunixdgsocket.h"
7 WvUnixDGSocket::WvUnixDGSocket(WvStringParm filename,
bool _server,
int perms)
17 setfd(socket(PF_UNIX, SOCK_DGRAM, 0));
22 seterr(
"No Socket available.");
27 fcntl(
getfd(), F_SETFL, O_RDWR|O_NONBLOCK);
34 setsockopt(
getfd(), SOL_SOCKET, SO_REUSEADDR, &x,
sizeof(x));
42 sockaddr *addr = uaddr.sockaddr();
43 if (bind(
getfd(), (sockaddr *)addr, uaddr.sockaddr_len()))
50 chmod(socketfile, perms);
55 sockaddr *addr = uaddr.sockaddr();
56 if (connect(
getfd(), (sockaddr *)addr, uaddr.sockaddr_len()))
58 seterr(
"Connect to %s failed: %s",
68 WvUnixDGSocket::~WvUnixDGSocket()
103 si.wants.writable =
true;
104 else if (si.msec_timeout < 0
118 si.wants.writable =
true;
127 WvBufList::Iter i(bufs);
128 for (i.rewind(); i.next(); )
130 int used = i->used();
time_t alarm_remaining()
return the number of milliseconds remaining before the alarm will go off; -1 means no alarm is set (i...
virtual size_t uwrite(const void *buf, size_t count)
unbuffered I/O functions; these ignore the buffer, which is handled by write().
static WvString strerror(int errnum)
A replacement for the operating system ::strerror() function that can map more kinds of error strings...
virtual size_t uwrite(const void *buf, size_t count)
unbuffered I/O functions; these ignore the buffer, which is handled by write().
virtual void seterr(int _errnum)
Override seterr() from WvError so that it auto-closes the stream.
virtual bool post_select(SelectInfo &si)
post_select() is called after ::select(), and returns true if this object is now ready.
void setfd(int fd)
Sets the file descriptor for both reading and writing.
the data structure used by pre_select()/post_select() and internally by select().
int getfd() const
Returns the Unix file descriptor for reading and writing.
virtual bool post_select(SelectInfo &si)
post_select() is called after ::select(), and returns true if this object is now ready.
void alarm(time_t msec_timeout)
set an alarm, ie.
virtual void pre_select(SelectInfo &si)
pre_select() sets up for eventually calling ::select().
A SelectRequest is a convenient way to remember what we want to do to a particular stream: read from ...
virtual void close()
Closes the file descriptors.
virtual void pre_select(SelectInfo &si)
pre_select() sets up for eventually calling ::select().
A Unix domain socket address is really just a filename.
void drain()
drain the input buffer (read and discard data until select(0) returns false)