X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FINetAddressing.cc;h=d96bd9302bf02d9c94a43aa4a97a6cfefb1e7d14;hb=a4911c1fd3f53dc2a7bda6c1d2b00bdc4b864cff;hp=013704d73bc2dc2e53dd71ab981eea2ad20b774f;hpb=9ff0a749115d3424608d7b077037258481c0086c;p=senf.git diff --git a/Socket/INetAddressing.cc b/Socket/INetAddressing.cc index 013704d..d96bd93 100644 --- a/Socket/INetAddressing.cc +++ b/Socket/INetAddressing.cc @@ -20,7 +20,9 @@ // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// Definition of non-inline non-template functions +/** \file + \brief INet[46]Address and INet[46]AddressingPolicy non-inline non-template implementation + */ #include "INetAddressing.hh" //#include "INetAddressing.ih" @@ -35,16 +37,16 @@ #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// -prefix_ satcom::lib::INet4Address::INet4Address(std::string host, unsigned port) +prefix_ senf::INet4Address::INet4Address(std::string host, unsigned port) { clear(); - // TODO: gethostbyname einbauen + /** \todo gethostbyname support */ if (::inet_aton(host.c_str(), &addr_.sin_addr) == 0) throw InvalidINetAddressException(); addr_.sin_port = htons(port); } -prefix_ std::string satcom::lib::INet4Address::str() +prefix_ std::string senf::INet4Address::str() const { std::stringstream s; @@ -52,26 +54,27 @@ prefix_ std::string satcom::lib::INet4Address::str() return s.str(); } -prefix_ void satcom::lib::INet4Address::clear() +prefix_ void senf::INet4Address::clear() { ::memset(&addr_,0,sizeof(addr_)); addr_.sin_family = AF_INET; } -prefix_ void satcom::lib::INet4Address::assignString(std::string address) +prefix_ void senf::INet4Address::assignString(std::string address) { clear(); - // TODO: gethostbyname einbauen unsigned i = address.find(':'); if (i == std::string::npos) throw InvalidINetAddressException(); + // The temporary string in the next expr is guaranteed to live + // until end-of-statement if (::inet_aton(std::string(address,0,i).c_str(), &addr_.sin_addr) == 0) throw InvalidINetAddressException(); try { // Replace lexical_cast with strtoul ? addr_.sin_port = htons(boost::lexical_cast< ::u_int16_t >(std::string(address,i+1))); } - catch (boost::bad_lexical_cast const & ex) { + catch (boost::bad_lexical_cast const &) { throw InvalidINetAddressException(); } } @@ -83,5 +86,5 @@ prefix_ void satcom::lib::INet4Address::assignString(std::string address) // Local Variables: // mode: c++ -// c-file-style: "satcom" +// c-file-style: "senf" // End: