22 #include <linux/filter.h> 23 #include <sys/types.h> 24 #include <sys/socket.h> 25 #include <sys/ioctl.h> 26 #include <netinet/ip.h> 37 socklen_t len =
sizeof(ling);
38 ::memset(&ling, 0,
sizeof(ling));
39 if (::getsockopt(
fd(),SOL_SOCKET,SO_LINGER,&ling,&len) < 0)
41 return std::make_pair(ling.l_onoff, ling.l_linger);
48 ling.l_onoff = enable;
49 ling.l_linger = timeout;
50 if (::setsockopt(
fd(),SOL_SOCKET,SO_LINGER,&ling,
sizeof(ling)) < 0)
58 socklen_t len (
sizeof(value));
59 if (::getsockopt(
fd(),SOL_SOCKET,SO_PRIORITY,&value,&len) < 0)
68 if (::setsockopt(
fd(),SOL_SOCKET,SO_PRIORITY,&ivalue,
sizeof(ivalue)) < 0)
76 socklen_t len (
sizeof(err));
77 if (::getsockopt(
fd(),SOL_SOCKET,SO_ERROR,&err,&len) < 0)
86 socklen_t len (
sizeof(size));
87 if (::getsockopt(
fd(),SOL_SOCKET,SO_RCVBUF,&size,&len) < 0)
97 if (::setsockopt(
fd(),SOL_SOCKET,SO_RCVBUF,&size,
sizeof(size)) < 0)
105 socklen_t len (
sizeof(size));
106 if (::getsockopt(
fd(),SOL_SOCKET,SO_SNDBUF,&size,&len) < 0)
116 if (::setsockopt(
fd(),SOL_SOCKET,SO_SNDBUF,&size,
sizeof(size)) < 0)
123 if (::setsockopt(
fd(), SOL_SOCKET, SO_DETACH_FILTER, &dummy,
sizeof(dummy)) < 0)
127 prefix_ void senf::BSDSocketProtocol::do_attachSocketFilter(::sock_filter * filter,
unsigned short len)
129 struct sock_fprog sockArg;
130 sockArg.filter = filter;
132 if (::setsockopt(
fd(), SOL_SOCKET, SO_ATTACH_FILTER, &sockArg,
sizeof(sockArg)) < 0)
139 if (::setsockopt(
fd(), IPPROTO_IP, IP_MTU_DISCOVER, &mode,
sizeof(mode)) < 0)
146 if (::setsockopt(
fd(), SOL_SOCKET, SO_SNDLOWAT, &lowat,
sizeof(lowat)) < 0)
153 if (::setsockopt(
fd(), SOL_SOCKET, SO_RCVLOWAT, &lowat,
sizeof(lowat)) < 0)
163 socklen_t len (
sizeof(value));
164 if (::getsockopt(
fd(),SOL_SOCKET,SO_REUSEADDR,&value,&len) < 0)
173 if (::setsockopt(
fd(),SOL_SOCKET,SO_REUSEADDR,&ivalue,
sizeof(ivalue)) < 0)
void mtuDiscovery(int mode) const
#define SENF_THROW_SYSTEM_EXCEPTION(desc)
unsigned rcvbuf() const
Check receive buffer size.
bool reuseaddr() const
Return current reuseaddr state.
int fd() const
Get file descriptor.
void detachSocketFilter()
void sndLowat(unsigned lowWat) const
unsigned sndbuf() const
Check send buffer size.
boost::uint8_t priority() const
Get packet priority assigned to outgoing packets.
std::pair< bool, unsigned > linger() const
Return current linger status.
int error() const
Get and clear pending socket error.
void rcvLowat(unsigned lowWat) const
BSDSocketProtocol public header.