X-Git-Url: http://developer.intra2net.com/git/?p=libt2n;a=blobdiff_plain;f=src%2Fsocket_handler.hxx;h=82ccdad368a6e13edd53c606ea6c2955688f5301;hp=e249cf5b950558f46a2a7ab0127d1b694de33885;hb=2c49df2a77df8ded0ee565cccf5ed784f46d0f37;hpb=a11e19b7adab2d5b937573701959562f06087ac5 diff --git a/src/socket_handler.hxx b/src/socket_handler.hxx index e249cf5..82ccdad 100644 --- a/src/socket_handler.hxx +++ b/src/socket_handler.hxx @@ -19,11 +19,16 @@ #ifndef __LIBT2N_SOCKET_HANDLER #define __LIBT2N_SOCKET_HANDLER +#include + #include "types.hxx" namespace libt2n { +/** @brief handles socket based communication. + Don't use directly, use socket_server or socket_client_connection instead. +*/ class socket_handler { private: @@ -32,7 +37,7 @@ class socket_handler socket_type_value socket_type; - bool data_waiting(long long usec_timeout=-1); + bool data_waiting(long long usec_timeout,long long *timeout_remaining=NULL); protected: int sock; @@ -42,21 +47,22 @@ class socket_handler void set_socket_options(int sock); - void log(log_level_values level, const std::string& message) - { log(level,message.c_str()); } - virtual void log(log_level_values level, const char* message) - { return; } + virtual std::ostream* get_logstream(log_level_values level) + { return NULL; } - public: - socket_type_value get_type() - { return socket_type; } + void socket_write(const std::string& data); - bool fill_buffer(std::string& buffer, long long usec_timeout); + virtual void close(); + + bool fill_buffer(std::string& buffer, long long usec_timeout, long long*timeout_remaining=NULL); bool fill_buffer(std::string& buffer); - void close(); + public: + /// is this a tcp or udp socket connection + socket_type_value get_type() + { return socket_type; } - void write(const std::string& data); + bool is_closed(); }; }