X-Git-Url: http://developer.intra2net.com/git/?p=libt2n;a=blobdiff_plain;f=src%2Fsocket_server.hxx;h=605613682d18a8ab893ff3782106539c8ec5e1d0;hp=ca2f03cbdfa88168bdc0e7f5b44819f8e8ffbc4f;hb=aa499d2034964a4c125794b7e8ea768cb7471411;hpb=ac7fdc22899c0c493fda5fdb3a4cb67e77504a6b diff --git a/src/socket_server.hxx b/src/socket_server.hxx index ca2f03c..6056136 100644 --- a/src/socket_server.hxx +++ b/src/socket_server.hxx @@ -26,43 +26,54 @@ namespace libt2n { +/** + Socket based server class +*/ class socket_server : public server { public: - enum socket_type { tcp, unix }; + enum socket_type_value { tcp_s, unix_s }; private: - int socket; + int sock; fd_set connection_set; - socket_type type; - string unix_path; + socket_type_value socket_type; + std::string unix_path; + + void set_socket_options(int sock); + void new_connection(); public: socket_server(int port, const char* ip="0.0.0.0"); - socket_server(const char* path, mode_t chmod, const char* user="", const char* group=""); + socket_server(const char* path, mode_t filemode, const char* user="", const char* group=""); ~socket_server(); - socket_type get_type() - { return type; } + socket_type_value get_type() + { return socket_type; } void fill_buffer(long long usec_timeout=-1); + void fill_connection_buffers(); }; +/** + Socket based connection class +*/ class socket_connection : public connection { + friend class socket_server; + private: - int socket; + static const int recv_buffer_size=2048; + + int sock; - friend void socket_server::fill_buffer(long long usec_timeout); - socket_connection(int _socket, int _timeout); + socket_connection(int _sock, int _timeout); public: void close(); - - void fill_buffer(void); - + void fill_buffer(fd_set &cur_fdset); void write(const std::string& data); };