mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 15:33:54 +01:00
ircd::net: Additional socket option accoutrements.
This commit is contained in:
parent
ebad745a3f
commit
6aec038479
2 changed files with 75 additions and 0 deletions
|
@ -84,11 +84,18 @@ struct ircd::net::socket
|
|||
size_t readable() const; // throws on errors; ioctl
|
||||
size_t rbufsz() const; // throws on errors; SO_RCVBUF
|
||||
size_t wbufsz() const; // throws on errors; SO_SNDBUF
|
||||
size_t rlowat() const; // throws on errors; SO_RCVLOWAT
|
||||
size_t wlowat() const; // throws on errors; SO_SNDLOWWAT
|
||||
bool blocking() const; // throws on errors;
|
||||
bool nodelay() const; // throws on errors;
|
||||
|
||||
void rbufsz(const size_t &); // throws; set SO_RCVBUF bytes
|
||||
void wbufsz(const size_t &); // throws; set SO_RCVBUF bytes
|
||||
void rlowat(const size_t &); // throws; set SO_RCVLOWAT bytes
|
||||
void wlowat(const size_t &); // throws; set SO_SNDLOWAT bytes
|
||||
void blocking(const bool &); // throws; set blocking
|
||||
void nodelay(const bool &); // throws; TCP_NODELAY
|
||||
void flush(); // throws; toggles TCP_NODELAY
|
||||
|
||||
// low level read suite
|
||||
template<class iov> auto read_some(const iov &, xfer_handler);
|
||||
|
|
68
ircd/net.cc
68
ircd/net.cc
|
@ -1342,12 +1342,53 @@ catch(const std::exception &e)
|
|||
e.what());
|
||||
}
|
||||
|
||||
void
|
||||
ircd::net::socket::flush()
|
||||
{
|
||||
if(nodelay())
|
||||
return;
|
||||
|
||||
nodelay(true);
|
||||
nodelay(false);
|
||||
}
|
||||
|
||||
void
|
||||
ircd::net::socket::nodelay(const bool &b)
|
||||
{
|
||||
ip::tcp::no_delay option{b};
|
||||
sd.set_option(option);
|
||||
}
|
||||
|
||||
void
|
||||
ircd::net::socket::blocking(const bool &b)
|
||||
{
|
||||
sd.non_blocking(b);
|
||||
}
|
||||
|
||||
void
|
||||
ircd::net::socket::wlowat(const size_t &bytes)
|
||||
{
|
||||
assert(bytes <= std::numeric_limits<int>::max());
|
||||
ip::tcp::socket::send_low_watermark option
|
||||
{
|
||||
int(bytes)
|
||||
};
|
||||
|
||||
sd.set_option(option);
|
||||
}
|
||||
|
||||
void
|
||||
ircd::net::socket::rlowat(const size_t &bytes)
|
||||
{
|
||||
assert(bytes <= std::numeric_limits<int>::max());
|
||||
ip::tcp::socket::receive_low_watermark option
|
||||
{
|
||||
int(bytes)
|
||||
};
|
||||
|
||||
sd.set_option(option);
|
||||
}
|
||||
|
||||
void
|
||||
ircd::net::socket::wbufsz(const size_t &bytes)
|
||||
{
|
||||
|
@ -1372,6 +1413,15 @@ ircd::net::socket::rbufsz(const size_t &bytes)
|
|||
sd.set_option(option);
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::net::socket::nodelay()
|
||||
const
|
||||
{
|
||||
ip::tcp::no_delay option;
|
||||
sd.get_option(option);
|
||||
return option.value();
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::net::socket::blocking()
|
||||
const
|
||||
|
@ -1379,6 +1429,24 @@ const
|
|||
return !sd.non_blocking();
|
||||
}
|
||||
|
||||
size_t
|
||||
ircd::net::socket::wlowat()
|
||||
const
|
||||
{
|
||||
ip::tcp::socket::send_low_watermark option{};
|
||||
sd.get_option(option);
|
||||
return option.value();
|
||||
}
|
||||
|
||||
size_t
|
||||
ircd::net::socket::rlowat()
|
||||
const
|
||||
{
|
||||
ip::tcp::socket::receive_low_watermark option{};
|
||||
sd.get_option(option);
|
||||
return option.value();
|
||||
}
|
||||
|
||||
size_t
|
||||
ircd::net::socket::wbufsz()
|
||||
const
|
||||
|
|
Loading…
Reference in a new issue