1 #include "wvunixdgsocket.h"
5 WvUnixDGSocket::WvUnixDGSocket(
WvStringParm filename,
bool _server,
int perms)
15 setfd(socket(PF_UNIX, SOCK_DGRAM, 0));
20 seterr(
"No Socket available.");
25 fcntl(
getfd(), F_SETFL, O_RDWR|O_NONBLOCK);
32 setsockopt(
getfd(), SOL_SOCKET, SO_REUSEADDR, &x,
sizeof(x));
40 sockaddr *addr = uaddr.sockaddr();
41 if (bind(
getfd(), (sockaddr *)addr, uaddr.sockaddr_len()))
48 chmod(socketfile, perms);
53 sockaddr *addr = uaddr.sockaddr();
54 if (connect(
getfd(), (sockaddr *)addr, uaddr.sockaddr_len()))
56 seterr(
"Connect to %s failed: %s",
66 WvUnixDGSocket::~WvUnixDGSocket()
101 si.wants.writable =
true;
102 else if (si.msec_timeout < 0
116 si.wants.writable =
true;
125 WvBufList::Iter i(bufs);
126 for (i.rewind(); i.next(); )
128 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.
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
void drain()
drain the input buffer (read and discard data until select(0) returns false)