3 #include <boost/utility/string_ref.hpp> 5 int SConnectWithTimeout(
int sockfd,
const ComboAddress& remote,
double timeout);
10 RAIISocket(
int domain,
int type,
int protocol=0)
12 d_fd =
SSocket(domain, type, protocol);
45 explicit ReadBuffer(
int fd,
int bufsize=2048) : d_fd(fd), d_buffer(bufsize)
57 if(d_pos == d_endpos && !getMoreData())
66 std::vector<char> d_buffer;
67 unsigned int d_pos{0};
68 unsigned int d_endpos{0};
88 SConnectWithTimeout(d_fd, a, d_timeout);
91 bool getLine(std::string& line);
94 void writen(boost::string_ref message);
101 double d_timeout{-1};
Definition: comboaddress.hh:78
Definition: sclasses.hh:7
void setTimeout(double timeout)
Set the timeout (in seconds)
Definition: sclasses.hh:97
int SSocket(int family, int type, int flags=0)
Create a socket. Error = exception.
Definition: swrappers.cc:14
Set of C++ friendly wrappers around socket-relevant calls.
Definition: sclasses.hh:41
void setTimeout(double timeout)
Set timeout in seconds.
Definition: sclasses.hh:49
void connect(const ComboAddress &a)
Connect to an address, with the default timeout (which may be infinite)
Definition: sclasses.hh:86
ReadBuffer(int fd, int bufsize=2048)
Instantiate on a non-blocking filedescriptor, with a given buffer size in bytes.
Definition: sclasses.hh:45
Definition: sclasses.hh:77
SocketCommunicator(int fd)
Instantiate on top of this file descriptor, which will be set to non-blocking.
Definition: sclasses.hh:81
bool getChar(char *c)
Gets you a character in c, or false in case of EOF.
Definition: sclasses.hh:55
void SetNonBlocking(int sockfd, bool to=true)
Set a socket to (non) blocking mode. Error = exception.
Definition: swrappers.cc:99