1#include "wvunixdgsocket.h"
5WvUnixDGSocket::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()))
43 seterr(
"Bind to %s failed: %s", socketfile, strerror(errno));
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",
57 socketfile, strerror(errno));
66WvUnixDGSocket::~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();
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
virtual void close()
Closes the file descriptors.
virtual bool post_select(SelectInfo &si)
post_select() is called after ::select(), and returns true if this object is now ready.
virtual void pre_select(SelectInfo &si)
pre_select() sets up for eventually calling ::select().
virtual size_t uwrite(const void *buf, size_t count)
unbuffered I/O functions; these ignore the buffer, which is handled by write().
void alarm(time_t msec_timeout)
set an alarm, ie.
time_t alarm_remaining()
return the number of milliseconds remaining before the alarm will go off; -1 means no alarm is set (i...
A Unix domain socket address is really just a filename.
virtual size_t uwrite(const void *buf, size_t count)
unbuffered I/O functions; these ignore the buffer, which is handled by write().
virtual bool post_select(SelectInfo &si)
post_select() is called after ::select(), and returns true if this object is now ready.
virtual void pre_select(SelectInfo &si)
pre_select() sets up for eventually calling ::select().
the data structure used by pre_select()/post_select() and internally by select().
A SelectRequest is a convenient way to remember what we want to do to a particular stream: read from ...