00001 #ifndef USOCKSTREAMBUF_H 00002 #define USOCKSTREAMBUF_H 00003 // $Id: usockstreambuf.h,v 1.3 2002/10/18 18:15:37 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 /** 00015 * Dv::Util::fdstreambuf specialization for unix sockets. 00016 */ 00017 class usockstreambuf: public Dv::Util::fdstreambuf { 00018 /** 00019 * Usocket is friend to allow access to Dv::Util::fdstreambuf::error(int) 00020 */ 00021 friend class usocket; 00022 public: 00023 /** 00024 * Constructor. 00025 * 00026 * \param in_buf_size size (in bytes) of input buffer. 00027 * \param out_buf_size size (in bytes) of output buffer. 00028 * \param delay (in milliseconds) if an I/O operation does not 00029 * complete in delay milliseconds, it will time out. 00030 * 00031 * \see Dv::Util::fdstreambuf::timedout(), Dv::Util::fdstreambuf 00032 */ 00033 explicit usockstreambuf(size_t in_buf_size=1024, 00034 size_t out_buf_size=1024, 00035 time_t delay=0); 00036 /** 00037 * Destructor. 00038 */ 00039 virtual ~usockstreambuf(); 00040 00041 /** 00042 * Create socket fd and bind to filename, return <0 if error. 00043 * 00044 * \param filename to which socket will be bound 00045 * \param err will receive error status, i.e. last system errno 00046 * \return 0 iff ok, -1 else. If -1 is returned, err will be set 00047 * to the last system errno. 00048 */ 00049 static int bind(const std::string& filename, int& err); 00050 /** 00051 * \return filename of this unix socket. 00052 */ 00053 const std::string& filename() const { return fn_; } 00054 00055 private: 00056 /** 00057 * Set filename associated with this unix socket. 00058 * \param fn filename to associate with this socket. 00059 */ 00060 void filename(const std::string& fn) { fn_ = fn; } 00061 /** 00062 * Filename associated with this unix socket. 00063 */ 00064 std::string fn_; 00065 }; 00066 00067 }} 00068 00069 #endif
dvnet-0.9.11 | [27 December, 2004] |