L:/channel/channel/include/ConnInfo.h

Go to the documentation of this file.
00001 
00002 // Copyright (c) 2005, 2006 Yigong Liu
00003 // Permission to use, copy, modify, distribute and sell this software for any 
00004 //     purpose is hereby granted without fee, provided that the above copyright 
00005 //     notice appear in all copies and that both that copyright notice and this 
00006 //     permission notice appear in supporting documentation.
00007 // The author makes no representations about the 
00008 //     suitability of this software for any purpose. It is provided "as is" 
00009 //     without express or implied warranty.
00011 
00012 #ifndef _CONN_INFO_
00013 #define _CONN_INFO_
00014 
00015 #include <string>
00016 #include <BaseDef.h>
00017 
00018 
00019 namespace channel {
00023   class  ConnInfo {
00024   public:
00025     Interface_Type type_;
00026     std::string ip_;  //ip addr or hostname
00027     u_short port_;
00028     std::string unix_addr_;
00029     bool valid_;
00030 
00031     ConnInfo() {}
00032 
00033     ConnInfo(const ConnInfo &ci) {
00034       type_ = ci.type_;
00035       ip_ = ci.ip_;
00036       port_ = ci.port_;
00037       unix_addr_ = ci.unix_addr_;
00038       valid_ = ci.valid_;
00039     }
00040 
00041     void parse(std::string conn_info);
00042 
00043     ConnInfo(std::string ip, int port) {
00044       ip_ = ip;
00045       port_ = port;
00046       type_ = INET_SOCK;
00047       valid_ = true;
00048     }
00049 
00050     void set(std::string ip, int port) {
00051       ip_= ip;
00052       port_= port;
00053       type_ = INET_SOCK;
00054       valid_ = true;
00055     }
00056    
00057     ConnInfo(std::string addr) {
00058       parse(addr);
00059     }
00060 
00061     void set(std::string addr) {
00062       parse(addr);
00063     }
00064 
00065     Interface_Type type(void) { return type_;}
00066 
00067     bool valid(void) { return valid_; }
00068 
00069     std::string ip(void) { return ip_;}
00070     void ip(std::string ip) { ip_ = ip; }
00071     u_short port(void) {return port_;}
00072     void port(u_short p) {
00073       port_= p;
00074     }
00075 
00076     std::string get_host_addr(void) { return ip_;}
00077     void set_host_addr(std::string hn) { ip_ = hn;}
00078     u_short get_port_number(void) { return port_;}
00079     void set_port_number(u_short p) { port(p);}
00080 
00081     std::string unix_addr(void) { return unix_addr_;}
00082 
00083     bool operator< (const ConnInfo &ci) const;
00084     bool operator== (const ConnInfo &ci) const;
00085     void dump(void);
00086   
00087   };
00088 
00089 };
00090 
00091 #endif
00092 

Generated on Mon Feb 27 19:59:21 2006 for channel by  doxygen 1.4.6-NO