namespace libt2n
{
+/// set options like fast reuse and keepalive every socket should have
void socket_handler::set_socket_options(int sock)
{
int i=1;
}
}
+/// close the underlying socket connection. Don't call directly, use the version provided
+/// by the connection class you are using.
void socket_handler::close()
{
// graceful shutdown
::close(sock);
}
+/// is the underlying socket connection still open?
bool socket_handler::is_closed()
{
int r=fcntl(sock,F_GETFL);
return !(r & O_ACCMODE);
}
+/** @brief check if new data is waiting on the raw socket
+ @param usec_timeout wait until new data is found, max timeout usecs.
+ -1: wait endless
+ NULL: no timeout
+*/
bool socket_handler::data_waiting(long long usec_timeout)
{
// just our socket
return false;
}
+/** @brief read data from the raw socket and copy it into the provided buffer
+ @param buffer the buffer where to append the new data
+ @param usec_timeout wait until new data is found, max timeout usecs.
+ -1: wait endless
+ NULL: no timeout
+*/
bool socket_handler::fill_buffer(std::string& buffer, long long usec_timeout)
{
// fast path for timeout==0
return false;
}
+/** @brief read data from the raw socket and copy it into the provided buffer. Returns
+ instantly if no data is waiting.
+ @param buffer the buffer where to append the new data
+*/
bool socket_handler::fill_buffer(std::string& buffer)
{
bool try_again=false;
return false;
}
+/// writes raw data to the socket. Don't use directly, use the write() function provided by the
+/// connection because it encapsulates the data.
void socket_handler::socket_write(const std::string& data)
{
int offset = 0;