00001 #ifndef DV_NET_USOCKSTREAMBUF_H 00002 #define DV_NET_USOCKSTREAMBUF_H 00003 // $Id: usockstreambuf.h,v 1.6 2008/03/14 21:52:47 dvermeir Exp $ 00004 #include <dvutil/fdstreambuf.h> 00005 #include <string> 00006 #include <stdexcept> 00007 00008 /** @file 00009 * The Dv::Net::usockstreambuf class specializes 00010 * Dv::Util::fdstreambuf for use by Dv::Net::usockstream. 00011 */ 00012 namespace Dv { 00013 namespace Net { 00014 /** Dv::Util::fdstreambuf specialization for unix sockets. */ 00015 class usockstreambuf: public Dv::Util::fdstreambuf { 00016 /** Usocket is friend to allow access to Dv::Util::fdstreambuf::error(int) */ 00017 friend class usocket; 00018 public: 00019 /** Constructor. 00020 * @param in_buf_size size (in bytes) of input buffer. 00021 * @param out_buf_size size (in bytes) of output buffer. 00022 * @param delay (in milliseconds) if an I/O operation does not 00023 * complete in delay milliseconds, it will time out. 00024 * @param min_debug_level if a debug_master is connected, logging info 00025 * will only be written if the master's level is at least @a min_debug_level 00026 * @param debug_master from where debug info will be taken 00027 * @see Dv::DebugSlave 00028 * @see Dv::Util::fdstreambuf::timedout(), Dv::Util::fdstreambuf 00029 */ 00030 explicit usockstreambuf(size_t in_buf_size=1024, size_t out_buf_size=1024, time_t delay=0, 00031 unsigned int min_debug_level = 0, Debugable* debug_master = 0); 00032 /** Destructor. */ 00033 virtual ~usockstreambuf(); 00034 00035 /** Create socket fd and bind to filename, return <0 if error. 00036 * @param filename to which socket will be bound 00037 * @param err will receive error status, i.e. last system errno 00038 * @return 0 iff ok, -1 else. If -1 is returned, err will be set 00039 * to the last system errno. 00040 */ 00041 static int bind(const std::string& filename, int& err); 00042 /** @return filename of this unix socket. */ 00043 const std::string& filename() const { return fn_; } 00044 private: 00045 /** Set filename associated with this unix socket. 00046 * @param fn filename to associate with this socket. 00047 */ 00048 void filename(const std::string& fn) { fn_ = fn; } 00049 /** Filename associated with this unix socket. */ 00050 std::string fn_; 00051 }; 00052 } 00053 } 00054 #endif
dvnet-0.9.24 | [ 5 December, 2009] |