summaryrefslogtreecommitdiff
path: root/boost/asio/ip/detail/impl/endpoint.ipp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/asio/ip/detail/impl/endpoint.ipp')
-rw-r--r--boost/asio/ip/detail/impl/endpoint.ipp33
1 files changed, 18 insertions, 15 deletions
diff --git a/boost/asio/ip/detail/impl/endpoint.ipp b/boost/asio/ip/detail/impl/endpoint.ipp
index 24bfce2931..4ad504612b 100644
--- a/boost/asio/ip/detail/impl/endpoint.ipp
+++ b/boost/asio/ip/detail/impl/endpoint.ipp
@@ -2,7 +2,7 @@
// ip/detail/impl/endpoint.ipp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -17,9 +17,9 @@
#include <boost/asio/detail/config.hpp>
#include <cstring>
-#if !defined(BOOST_NO_IOSTREAM)
+#if !defined(BOOST_ASIO_NO_IOSTREAM)
# include <sstream>
-#endif // !defined(BOOST_NO_IOSTREAM)
+#endif // !defined(BOOST_ASIO_NO_IOSTREAM)
#include <boost/asio/detail/socket_ops.hpp>
#include <boost/asio/detail/throw_error.hpp>
#include <boost/asio/error.hpp>
@@ -35,25 +35,25 @@ namespace detail {
endpoint::endpoint()
: data_()
{
- data_.v4.sin_family = AF_INET;
+ data_.v4.sin_family = BOOST_ASIO_OS_DEF(AF_INET);
data_.v4.sin_port = 0;
- data_.v4.sin_addr.s_addr = INADDR_ANY;
+ data_.v4.sin_addr.s_addr = BOOST_ASIO_OS_DEF(INADDR_ANY);
}
endpoint::endpoint(int family, unsigned short port_num)
: data_()
{
using namespace std; // For memcpy.
- if (family == PF_INET)
+ if (family == BOOST_ASIO_OS_DEF(AF_INET))
{
- data_.v4.sin_family = AF_INET;
+ data_.v4.sin_family = BOOST_ASIO_OS_DEF(AF_INET);
data_.v4.sin_port =
boost::asio::detail::socket_ops::host_to_network_short(port_num);
- data_.v4.sin_addr.s_addr = INADDR_ANY;
+ data_.v4.sin_addr.s_addr = BOOST_ASIO_OS_DEF(INADDR_ANY);
}
else
{
- data_.v6.sin6_family = AF_INET6;
+ data_.v6.sin6_family = BOOST_ASIO_OS_DEF(AF_INET6);
data_.v6.sin6_port =
boost::asio::detail::socket_ops::host_to_network_short(port_num);
data_.v6.sin6_flowinfo = 0;
@@ -76,23 +76,26 @@ endpoint::endpoint(const boost::asio::ip::address& addr,
using namespace std; // For memcpy.
if (addr.is_v4())
{
- data_.v4.sin_family = AF_INET;
+ data_.v4.sin_family = BOOST_ASIO_OS_DEF(AF_INET);
data_.v4.sin_port =
boost::asio::detail::socket_ops::host_to_network_short(port_num);
data_.v4.sin_addr.s_addr =
boost::asio::detail::socket_ops::host_to_network_long(
- addr.to_v4().to_ulong());
+ static_cast<boost::asio::detail::u_long_type>(
+ addr.to_v4().to_ulong()));
}
else
{
- data_.v6.sin6_family = AF_INET6;
+ data_.v6.sin6_family = BOOST_ASIO_OS_DEF(AF_INET6);
data_.v6.sin6_port =
boost::asio::detail::socket_ops::host_to_network_short(port_num);
data_.v6.sin6_flowinfo = 0;
boost::asio::ip::address_v6 v6_addr = addr.to_v6();
boost::asio::ip::address_v6::bytes_type bytes = v6_addr.to_bytes();
memcpy(data_.v6.sin6_addr.s6_addr, bytes.data(), 16);
- data_.v6.sin6_scope_id = v6_addr.scope_id();
+ data_.v6.sin6_scope_id =
+ static_cast<boost::asio::detail::u_long_type>(
+ v6_addr.scope_id());
}
}
@@ -174,7 +177,7 @@ bool operator<(const endpoint& e1, const endpoint& e2)
return e1.port() < e2.port();
}
-#if !defined(BOOST_NO_IOSTREAM)
+#if !defined(BOOST_ASIO_NO_IOSTREAM)
std::string endpoint::to_string(boost::system::error_code& ec) const
{
std::string a = address().to_string(ec);
@@ -191,7 +194,7 @@ std::string endpoint::to_string(boost::system::error_code& ec) const
return tmp_os.str();
}
-#endif // !defined(BOOST_NO_IOSTREAM)
+#endif // !defined(BOOST_ASIO_NO_IOSTREAM)
} // namespace detail
} // namespace ip