// 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"
// Custom includes
-#include <strstream>
+#include <sstream>
#include <string.h>
#include <sys/socket.h>
#include <boost/lexical_cast.hpp>
#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;
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();
}
}
\f
// Local Variables:
// mode: c++
-// c-file-style: "satcom"
+// c-file-style: "senf"
// End: