21 #include <sys/socket.h> 22 #include <netinet/in.h> 36 if (::setsockopt(
fd(), SOL_SOCKET, SO_BINDTODEVICE, iface.c_str(), iface.size()) < 0)
43 socklen_t size (
sizeof(iface));
44 ::memset(iface, 0,
sizeof(iface));
45 if (::getsockopt(
fd(), SOL_SOCKET, SO_BINDTODEVICE, iface, &size) < 0)
47 iface[size < IFNAMSIZ ? size : IFNAMSIZ-1] = 0;
#define SENF_THROW_SYSTEM_EXCEPTION(desc)
int fd() const
Get file descriptor.
IPv[46]Protocol public header.
std::string bindInterface()
Get bound interface.