|
Boost-Commit : |
From: chris_at_[hidden]
Date: 2007-09-20 18:33:30
Author: chris_kohlhoff
Date: 2007-09-20 18:33:29 EDT (Thu, 20 Sep 2007)
New Revision: 39432
URL: http://svn.boost.org/trac/boost/changeset/39432
Log:
Eliminate use of types and structure members that may not be present when
build for non-XOPEN targets.
Text files modified:
trunk/boost/asio/detail/reactive_socket_service.hpp | 12 +-
trunk/boost/asio/detail/socket_ops.hpp | 235 ++++++++++++++++++++++++++-------------
trunk/boost/asio/detail/socket_select_interrupter.hpp | 2
trunk/boost/asio/detail/socket_types.hpp | 2
trunk/boost/asio/detail/win_iocp_socket_service.hpp | 17 +-
trunk/boost/asio/ip/basic_endpoint.hpp | 16 --
trunk/boost/asio/ip/basic_resolver_iterator.hpp | 4
7 files changed, 176 insertions(+), 112 deletions(-)
Modified: trunk/boost/asio/detail/reactive_socket_service.hpp
==============================================================================
--- trunk/boost/asio/detail/reactive_socket_service.hpp (original)
+++ trunk/boost/asio/detail/reactive_socket_service.hpp 2007-09-20 18:33:29 EDT (Thu, 20 Sep 2007)
@@ -451,7 +451,7 @@
}
endpoint_type endpoint;
- socket_addr_len_type addr_len = endpoint.capacity();
+ std::size_t addr_len = endpoint.capacity();
if (socket_ops::getsockname(impl.socket_, endpoint.data(), &addr_len, ec))
return endpoint_type();
endpoint.resize(addr_len);
@@ -469,7 +469,7 @@
}
endpoint_type endpoint;
- socket_addr_len_type addr_len = endpoint.capacity();
+ std::size_t addr_len = endpoint.capacity();
if (socket_ops::getpeername(impl.socket_, endpoint.data(), &addr_len, ec))
return endpoint_type();
endpoint.resize(addr_len);
@@ -1074,7 +1074,7 @@
for (;;)
{
// Try to complete the operation without blocking.
- socket_addr_len_type addr_len = sender_endpoint.capacity();
+ std::size_t addr_len = sender_endpoint.capacity();
int bytes_recvd = socket_ops::recvfrom(impl.socket_, bufs, i, flags,
sender_endpoint.data(), &addr_len, ec);
@@ -1145,7 +1145,7 @@
}
// Receive some data.
- socket_addr_len_type addr_len = sender_endpoint_.capacity();
+ std::size_t addr_len = sender_endpoint_.capacity();
boost::system::error_code ec;
int bytes = socket_ops::recvfrom(socket_, bufs, i, flags_,
sender_endpoint_.data(), &addr_len, ec);
@@ -1243,7 +1243,7 @@
// Try to complete the operation without blocking.
boost::system::error_code ec;
socket_holder new_socket;
- socket_addr_len_type addr_len = 0;
+ std::size_t addr_len = 0;
if (peer_endpoint)
{
addr_len = peer_endpoint->capacity();
@@ -1328,7 +1328,7 @@
// Accept the waiting connection.
boost::system::error_code ec;
socket_holder new_socket;
- socket_addr_len_type addr_len = 0;
+ std::size_t addr_len = 0;
if (peer_endpoint_)
{
addr_len = peer_endpoint_->capacity();
Modified: trunk/boost/asio/detail/socket_ops.hpp
==============================================================================
--- trunk/boost/asio/detail/socket_ops.hpp (original)
+++ trunk/boost/asio/detail/socket_ops.hpp 2007-09-20 18:33:29 EDT (Thu, 20 Sep 2007)
@@ -26,14 +26,17 @@
#include <cerrno>
#include <boost/detail/workaround.hpp>
#include <new>
-#if defined(__MACH__) && defined(__APPLE__)
-# include <AvailabilityMacros.h>
-#endif // defined(__MACH__) && defined(__APPLE__)
#include <boost/asio/detail/pop_options.hpp>
#include <boost/asio/error.hpp>
#include <boost/asio/detail/socket_types.hpp>
+#if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
+# define BOOST_ASIO_SOCKET_CALL __stdcall
+#else
+# define BOOST_ASIO_SOCKET_CALL
+#endif
+
namespace boost {
namespace asio {
namespace detail {
@@ -61,15 +64,29 @@
return return_value;
}
+template <typename R, typename Arg1, typename Arg2, typename Arg3>
+inline socket_type call_accept(
+ R (BOOST_ASIO_SOCKET_CALL*)(Arg1, Arg2, Arg3*),
+ socket_type s, socket_addr_type* addr, std::size_t* addrlen)
+{
+ Arg3 tmp_addrlen = addrlen ? (Arg3)*addrlen : 0;
+ R result = ::accept(s, addr, addrlen ? &tmp_addrlen : 0);
+ if (addrlen)
+ *addrlen = (std::size_t)tmp_addrlen;
+ return result;
+}
+
inline socket_type accept(socket_type s, socket_addr_type* addr,
- socket_addr_len_type* addrlen, boost::system::error_code& ec)
+ std::size_t* addrlen, boost::system::error_code& ec)
{
clear_error(ec);
-#if defined(__MACH__) && defined(__APPLE__) || defined(__FreeBSD__)
- socket_type new_s = error_wrapper(::accept(s, addr, addrlen), ec);
+
+ socket_type new_s = error_wrapper(call_accept(
+ ::accept, s, addr, addrlen), ec);
if (new_s == invalid_socket)
return new_s;
+#if defined(__MACH__) && defined(__APPLE__) || defined(__FreeBSD__)
int optval = 1;
int result = error_wrapper(::setsockopt(new_s,
SOL_SOCKET, SO_NOSIGPIPE, &optval, sizeof(optval)), ec);
@@ -78,18 +95,24 @@
::close(new_s);
return invalid_socket;
}
+#endif
return new_s;
-#else
- return error_wrapper(::accept(s, addr, addrlen), ec);
-#endif
+}
+
+template <typename R, typename Arg1, typename Arg2, typename Arg3>
+inline socket_type call_bind(
+ R (BOOST_ASIO_SOCKET_CALL*)(Arg1, Arg2, Arg3),
+ socket_type s, const socket_addr_type* addr, std::size_t addrlen)
+{
+ return ::bind(s, addr, (Arg3)addrlen);
}
inline int bind(socket_type s, const socket_addr_type* addr,
- socket_addr_len_type addrlen, boost::system::error_code& ec)
+ std::size_t addrlen, boost::system::error_code& ec)
{
clear_error(ec);
- return error_wrapper(::bind(s, addr, addrlen), ec);
+ return error_wrapper(call_bind(::bind, s, addr, addrlen), ec);
}
inline int close(socket_type s, boost::system::error_code& ec)
@@ -108,11 +131,19 @@
return error_wrapper(::shutdown(s, what), ec);
}
+template <typename R, typename Arg1, typename Arg2, typename Arg3>
+inline socket_type call_connect(
+ R (BOOST_ASIO_SOCKET_CALL*)(Arg1, Arg2, Arg3),
+ socket_type s, const socket_addr_type* addr, std::size_t addrlen)
+{
+ return ::connect(s, addr, (Arg3)addrlen);
+}
+
inline int connect(socket_type s, const socket_addr_type* addr,
- socket_addr_len_type addrlen, boost::system::error_code& ec)
+ std::size_t addrlen, boost::system::error_code& ec)
{
clear_error(ec);
- return error_wrapper(::connect(s, addr, addrlen), ec);
+ return error_wrapper(call_connect(::connect, s, addr, addrlen), ec);
}
inline int listen(socket_type s, int backlog, boost::system::error_code& ec)
@@ -149,6 +180,28 @@
#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
}
+inline void init_msghdr_msg_name(void*& name, socket_addr_type* addr)
+{
+ name = addr;
+}
+
+inline void init_msghdr_msg_name(void*& name, const socket_addr_type* addr)
+{
+ name = const_cast<socket_addr_type*>(addr);
+}
+
+template <typename T>
+inline void init_msghdr_msg_name(T& name, socket_addr_type* addr)
+{
+ name = reinterpret_cast<T>(addr);
+}
+
+template <typename T>
+inline void init_msghdr_msg_name(T& name, const socket_addr_type* addr)
+{
+ name = reinterpret_cast<T>(const_cast<socket_addr_type*>(addr));
+}
+
inline int recv(socket_type s, buf* bufs, size_t count, int flags,
boost::system::error_code& ec)
{
@@ -164,20 +217,15 @@
return -1;
return bytes_transferred;
#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
- msghdr msg;
- msg.msg_name = 0;
- msg.msg_namelen = 0;
+ msghdr msg = msghdr();
msg.msg_iov = bufs;
msg.msg_iovlen = count;
- msg.msg_control = 0;
- msg.msg_controllen = 0;
- msg.msg_flags = 0;
return error_wrapper(::recvmsg(s, &msg, flags), ec);
#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
}
inline int recvfrom(socket_type s, buf* bufs, size_t count, int flags,
- socket_addr_type* addr, socket_addr_len_type* addrlen,
+ socket_addr_type* addr, std::size_t* addrlen,
boost::system::error_code& ec)
{
clear_error(ec);
@@ -186,25 +234,19 @@
DWORD recv_buf_count = static_cast<DWORD>(count);
DWORD bytes_transferred = 0;
DWORD recv_flags = flags;
+ int tmp_addrlen = (int)*addrlen;
int result = error_wrapper(::WSARecvFrom(s, bufs, recv_buf_count,
- &bytes_transferred, &recv_flags, addr, addrlen, 0, 0), ec);
+ &bytes_transferred, &recv_flags, addr, &tmp_addrlen, 0, 0), ec);
+ *addrlen = (std::size_t)tmp_addrlen;
if (result != 0)
return -1;
return bytes_transferred;
#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
- msghdr msg;
-#if defined(__MACH__) && defined(__APPLE__) \
- && (MAC_OS_X_VERSION_MAX_ALLOWED < 1040)
- msg.msg_name = reinterpret_cast<char*>(addr);
-#else
- msg.msg_name = addr;
-#endif
+ msghdr msg = msghdr();
+ init_msghdr_msg_name(msg.msg_name, addr);
msg.msg_namelen = *addrlen;
msg.msg_iov = bufs;
msg.msg_iovlen = count;
- msg.msg_control = 0;
- msg.msg_controllen = 0;
- msg.msg_flags = 0;
int result = error_wrapper(::recvmsg(s, &msg, flags), ec);
*addrlen = msg.msg_namelen;
return result;
@@ -226,14 +268,9 @@
return -1;
return bytes_transferred;
#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
- msghdr msg;
- msg.msg_name = 0;
- msg.msg_namelen = 0;
+ msghdr msg = msghdr();
msg.msg_iov = const_cast<buf*>(bufs);
msg.msg_iovlen = count;
- msg.msg_control = 0;
- msg.msg_controllen = 0;
- msg.msg_flags = 0;
#if defined(__linux__)
flags |= MSG_NOSIGNAL;
#endif // defined(__linux__)
@@ -242,7 +279,7 @@
}
inline int sendto(socket_type s, const buf* bufs, size_t count, int flags,
- const socket_addr_type* addr, socket_addr_len_type addrlen,
+ const socket_addr_type* addr, std::size_t addrlen,
boost::system::error_code& ec)
{
clear_error(ec);
@@ -256,19 +293,11 @@
return -1;
return bytes_transferred;
#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
- msghdr msg;
-#if defined(__MACH__) && defined(__APPLE__) \
- && (MAC_OS_X_VERSION_MAX_ALLOWED < 1040)
- msg.msg_name = reinterpret_cast<char*>(const_cast<socket_addr_type*>(addr));
-#else
- msg.msg_name = const_cast<socket_addr_type*>(addr);
-#endif
+ msghdr msg = msghdr();
+ init_msghdr_msg_name(msg.msg_name, addr);
msg.msg_namelen = addrlen;
msg.msg_iov = const_cast<buf*>(bufs);
msg.msg_iovlen = count;
- msg.msg_control = 0;
- msg.msg_controllen = 0;
- msg.msg_flags = 0;
#if defined(__linux__)
flags |= MSG_NOSIGNAL;
#endif // defined(__linux__)
@@ -317,8 +346,18 @@
#endif
}
+template <typename R, typename Arg1, typename Arg2,
+ typename Arg3, typename Arg4, typename Arg5>
+inline socket_type call_setsockopt(
+ R (BOOST_ASIO_SOCKET_CALL*)(Arg1, Arg2, Arg3, Arg4, Arg5),
+ socket_type s, int level, int optname,
+ const void* optval, std::size_t optlen)
+{
+ return ::setsockopt(s, level, optname, (Arg4)optval, (Arg5)optlen);
+}
+
inline int setsockopt(socket_type s, int level, int optname,
- const void* optval, size_t optlen, boost::system::error_code& ec)
+ const void* optval, std::size_t optlen, boost::system::error_code& ec)
{
if (level == custom_socket_option_level && optname == always_fail_option)
{
@@ -343,15 +382,24 @@
}
ec = boost::asio::error::fault;
return -1;
-#elif defined(BOOST_WINDOWS) || defined(__CYGWIN__)
- clear_error(ec);
- return error_wrapper(::setsockopt(s, level, optname,
- reinterpret_cast<const char*>(optval), static_cast<int>(optlen)), ec);
-#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
+#else // defined(__BORLANDC__)
clear_error(ec);
- return error_wrapper(::setsockopt(s, level, optname, optval,
- static_cast<socklen_t>(optlen)), ec);
-#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
+ return error_wrapper(call_setsockopt(::setsockopt,
+ s, level, optname, optval, optlen), ec);
+#endif // defined(__BORLANDC__)
+}
+
+template <typename R, typename Arg1, typename Arg2,
+ typename Arg3, typename Arg4, typename Arg5>
+inline socket_type call_getsockopt(
+ R (BOOST_ASIO_SOCKET_CALL*)(Arg1, Arg2, Arg3, Arg4, Arg5*),
+ socket_type s, int level, int optname,
+ const void* optval, std::size_t* optlen)
+{
+ Arg5 tmp_optlen = (Arg5)*optlen;
+ R result = ::getsockopt(s, level, optname, (Arg4)optval, &tmp_optlen);
+ *optlen = (std::size_t)tmp_optlen;
+ return result;
}
inline int getsockopt(socket_type s, int level, int optname, void* optval,
@@ -395,10 +443,8 @@
return -1;
#elif defined(BOOST_WINDOWS) || defined(__CYGWIN__)
clear_error(ec);
- int tmp_optlen = static_cast<int>(*optlen);
- int result = error_wrapper(::getsockopt(s, level, optname,
- reinterpret_cast<char*>(optval), &tmp_optlen), ec);
- *optlen = static_cast<size_t>(tmp_optlen);
+ int result = error_wrapper(call_getsockopt(::getsockopt,
+ s, level, optname, optval, optlen), ec);
if (result != 0 && level == IPPROTO_IPV6 && optname == IPV6_V6ONLY
&& ec.value() == WSAENOPROTOOPT && *optlen == sizeof(DWORD))
{
@@ -413,10 +459,8 @@
return result;
#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
clear_error(ec);
- socklen_t tmp_optlen = static_cast<socklen_t>(*optlen);
- int result = error_wrapper(::getsockopt(s, level, optname,
- optval, &tmp_optlen), ec);
- *optlen = static_cast<size_t>(tmp_optlen);
+ int result = error_wrapper(call_getsockopt(::getsockopt,
+ s, level, optname, optval, optlen), ec);
#if defined(__linux__)
if (result == 0 && level == SOL_SOCKET && *optlen == sizeof(int)
&& (optname == SO_SNDBUF || optname == SO_RCVBUF))
@@ -433,18 +477,40 @@
#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
}
+template <typename R, typename Arg1, typename Arg2, typename Arg3>
+inline socket_type call_getpeername(
+ R (BOOST_ASIO_SOCKET_CALL*)(Arg1, Arg2, Arg3*),
+ socket_type s, socket_addr_type* addr, std::size_t* addrlen)
+{
+ Arg3 tmp_addrlen = (Arg3)*addrlen;
+ R result = ::getpeername(s, addr, &tmp_addrlen);
+ *addrlen = (std::size_t)tmp_addrlen;
+ return result;
+}
+
inline int getpeername(socket_type s, socket_addr_type* addr,
- socket_addr_len_type* addrlen, boost::system::error_code& ec)
+ std::size_t* addrlen, boost::system::error_code& ec)
{
clear_error(ec);
- return error_wrapper(::getpeername(s, addr, addrlen), ec);
+ return error_wrapper(call_getpeername(::getpeername, s, addr, addrlen), ec);
+}
+
+template <typename R, typename Arg1, typename Arg2, typename Arg3>
+inline socket_type call_getsockname(
+ R (BOOST_ASIO_SOCKET_CALL*)(Arg1, Arg2, Arg3*),
+ socket_type s, socket_addr_type* addr, std::size_t* addrlen)
+{
+ Arg3 tmp_addrlen = (Arg3)*addrlen;
+ R result = ::getsockname(s, addr, &tmp_addrlen);
+ *addrlen = (std::size_t)tmp_addrlen;
+ return result;
}
inline int getsockname(socket_type s, socket_addr_type* addr,
- socket_addr_len_type* addrlen, boost::system::error_code& ec)
+ std::size_t* addrlen, boost::system::error_code& ec)
{
clear_error(ec);
- return error_wrapper(::getsockname(s, addr, addrlen), ec);
+ return error_wrapper(call_getsockname(::getsockname, s, addr, addrlen), ec);
}
inline int ioctl(socket_type s, long cmd, ioctl_arg_type* arg,
@@ -925,6 +991,13 @@
::operator delete(p);
}
+inline void gai_strcpy(char* target, const char* source, std::size_t max_size)
+{
+ using namespace std;
+ *target = 0;
+ strncat(target, source, max_size);
+}
+
enum { gai_clone_flag = 1 << 30 };
inline int gai_aistruct(addrinfo_type*** next, const addrinfo_type* hints,
@@ -1294,14 +1367,15 @@
if (host != 0 && host[0] != '\0' && hptr->h_name && hptr->h_name[0]
&& (hints.ai_flags & AI_CANONNAME) && canon == 0)
{
- canon = gai_alloc<char>(strlen(hptr->h_name) + 1);
+ std::size_t canon_len = strlen(hptr->h_name) + 1;
+ canon = gai_alloc<char>(canon_len);
if (canon == 0)
{
freeaddrinfo_emulation(aihead);
socket_ops::freehostent(hptr);
return EAI_MEMORY;
}
- strcpy(canon, hptr->h_name);
+ gai_strcpy(canon, hptr->h_name, canon_len);
}
// Create an addrinfo structure for each returned address.
@@ -1337,13 +1411,14 @@
}
else
{
- aihead->ai_canonname = gai_alloc<char>(strlen(search[0].host) + 1);
+ std::size_t canonname_len = strlen(search[0].host) + 1;
+ aihead->ai_canonname = gai_alloc<char>(canonname_len);
if (aihead->ai_canonname == 0)
{
freeaddrinfo_emulation(aihead);
return EAI_MEMORY;
}
- strcpy(aihead->ai_canonname, search[0].host);
+ gai_strcpy(aihead->ai_canonname, search[0].host, canonname_len);
}
}
gai_free(canon);
@@ -1365,7 +1440,7 @@
}
inline boost::system::error_code getnameinfo_emulation(
- const socket_addr_type* sa, socket_addr_len_type salen, char* host,
+ const socket_addr_type* sa, std::size_t salen, char* host,
std::size_t hostlen, char* serv, std::size_t servlen, int flags,
boost::system::error_code& ec)
{
@@ -1426,8 +1501,7 @@
*dot = 0;
}
}
- *host = '\0';
- strncat(host, hptr->h_name, hostlen);
+ gai_strcpy(host, hptr->h_name, hostlen);
socket_ops::freehostent(hptr);
}
else
@@ -1465,8 +1539,7 @@
servent* sptr = ::getservbyport(port, (flags & NI_DGRAM) ? "udp" : 0);
if (sptr && sptr->s_name && sptr->s_name[0] != '\0')
{
- *serv = '\0';
- strncat(serv, sptr->s_name, servlen);
+ gai_strcpy(serv, sptr->s_name, servlen);
}
else
{
@@ -1589,7 +1662,7 @@
}
inline boost::system::error_code getnameinfo(const socket_addr_type* addr,
- socket_addr_len_type addrlen, char* host, std::size_t hostlen,
+ std::size_t addrlen, char* host, std::size_t hostlen,
char* serv, std::size_t servlen, int flags, boost::system::error_code& ec)
{
#if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
@@ -1602,7 +1675,7 @@
# else
// Building for Windows 2000 or earlier.
typedef int (WSAAPI *gni_t)(const socket_addr_type*,
- socket_addr_len_type, char*, std::size_t, char*, std::size_t, int);
+ int, char*, std::size_t, char*, std::size_t, int);
if (HMODULE winsock_module = ::GetModuleHandleA("ws2_32"))
{
if (gni_t gni = (gni_t)::GetProcAddress(winsock_module, "getnameinfo"))
@@ -1657,6 +1730,8 @@
} // namespace asio
} // namespace boost
+#undef BOOST_ASIO_SOCKET_CALL
+
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_DETAIL_SOCKET_OPS_HPP
Modified: trunk/boost/asio/detail/socket_select_interrupter.hpp
==============================================================================
--- trunk/boost/asio/detail/socket_select_interrupter.hpp (original)
+++ trunk/boost/asio/detail/socket_select_interrupter.hpp 2007-09-20 18:33:29 EDT (Thu, 20 Sep 2007)
@@ -53,7 +53,7 @@
using namespace std; // For memset.
sockaddr_in4_type addr;
- socket_addr_len_type addr_len = sizeof(addr);
+ std::size_t addr_len = sizeof(addr);
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = inet_addr("127.0.0.1");
Modified: trunk/boost/asio/detail/socket_types.hpp
==============================================================================
--- trunk/boost/asio/detail/socket_types.hpp (original)
+++ trunk/boost/asio/detail/socket_types.hpp 2007-09-20 18:33:29 EDT (Thu, 20 Sep 2007)
@@ -117,7 +117,6 @@
const int max_addr_v4_str_len = 256;
const int max_addr_v6_str_len = 256;
typedef sockaddr socket_addr_type;
-typedef int socket_addr_len_type;
typedef in_addr in4_addr_type;
typedef ip_mreq in4_mreq_type;
typedef sockaddr_in sockaddr_in4_type;
@@ -155,7 +154,6 @@
const int max_addr_v4_str_len = INET_ADDRSTRLEN;
const int max_addr_v6_str_len = INET6_ADDRSTRLEN + 1 + IF_NAMESIZE;
typedef sockaddr socket_addr_type;
-typedef socklen_t socket_addr_len_type;
typedef in_addr in4_addr_type;
typedef ip_mreq in4_mreq_type;
typedef sockaddr_in sockaddr_in4_type;
Modified: trunk/boost/asio/detail/win_iocp_socket_service.hpp
==============================================================================
--- trunk/boost/asio/detail/win_iocp_socket_service.hpp (original)
+++ trunk/boost/asio/detail/win_iocp_socket_service.hpp 2007-09-20 18:33:29 EDT (Thu, 20 Sep 2007)
@@ -562,7 +562,7 @@
}
endpoint_type endpoint;
- socket_addr_len_type addr_len = endpoint.capacity();
+ std::size_t addr_len = endpoint.capacity();
if (socket_ops::getsockname(impl.socket_, endpoint.data(), &addr_len, ec))
return endpoint_type();
endpoint.resize(addr_len);
@@ -601,7 +601,7 @@
else
{
endpoint_type endpoint;
- socket_addr_len_type addr_len = endpoint.capacity();
+ std::size_t addr_len = endpoint.capacity();
if (socket_ops::getpeername(impl.socket_, endpoint.data(), &addr_len, ec))
return endpoint_type();
endpoint.resize(addr_len);
@@ -1262,7 +1262,7 @@
// Receive some data.
DWORD bytes_transferred = 0;
DWORD recv_flags = flags;
- int endpoint_size = sender_endpoint.capacity();
+ int endpoint_size = static_cast<int>(sender_endpoint.capacity());
int result = ::WSARecvFrom(impl.socket_, bufs, i, &bytes_transferred,
&recv_flags, sender_endpoint.data(), &endpoint_size, 0, 0);
if (result != 0)
@@ -1280,7 +1280,7 @@
return 0;
}
- sender_endpoint.resize(endpoint_size);
+ sender_endpoint.resize(static_cast<std::size_t>(endpoint_size));
ec = boost::system::error_code();
return bytes_transferred;
@@ -1300,7 +1300,7 @@
&receive_from_operation<
MutableBufferSequence, Handler>::destroy_impl),
endpoint_(endpoint),
- endpoint_size_(endpoint.capacity()),
+ endpoint_size_(static_cast<int>(endpoint.capacity())),
work_(io_service),
buffers_(buffers),
handler_(handler)
@@ -1464,7 +1464,7 @@
{
boost::system::error_code ec;
socket_holder new_socket;
- socket_addr_len_type addr_len = 0;
+ std::size_t addr_len = 0;
if (peer_endpoint)
{
addr_len = peer_endpoint->capacity();
@@ -1619,7 +1619,8 @@
GetAcceptExSockaddrs(handler_op->output_buffer(), 0,
handler_op->address_length(), handler_op->address_length(),
&local_addr, &local_addr_length, &remote_addr, &remote_addr_length);
- if (remote_addr_length > peer_endpoint.capacity())
+ if (static_cast<std::size_t>(remote_addr_length)
+ > peer_endpoint.capacity())
{
last_error = WSAEINVAL;
}
@@ -1627,7 +1628,7 @@
{
using namespace std; // For memcpy.
memcpy(peer_endpoint.data(), remote_addr, remote_addr_length);
- peer_endpoint.resize(remote_addr_length);
+ peer_endpoint.resize(static_cast<std::size_t>(remote_addr_length));
}
}
Modified: trunk/boost/asio/ip/basic_endpoint.hpp
==============================================================================
--- trunk/boost/asio/ip/basic_endpoint.hpp (original)
+++ trunk/boost/asio/ip/basic_endpoint.hpp 2007-09-20 18:33:29 EDT (Thu, 20 Sep 2007)
@@ -62,14 +62,6 @@
typedef boost::asio::detail::socket_addr_type data_type;
#endif
- /// The type for the size of the endpoint structure. This type is dependent on
- /// the underlying implementation of the socket layer.
-#if defined(GENERATING_DOCUMENTATION)
- typedef implementation_defined size_type;
-#else
- typedef boost::asio::detail::socket_addr_len_type size_type;
-#endif
-
/// Default constructor.
basic_endpoint()
: data_()
@@ -191,7 +183,7 @@
}
/// Get the underlying size of the endpoint in the native type.
- size_type size() const
+ std::size_t size() const
{
if (is_v4(data_))
return sizeof(boost::asio::detail::sockaddr_in4_type);
@@ -200,9 +192,9 @@
}
/// Set the underlying size of the endpoint in the native type.
- void resize(size_type size)
+ void resize(std::size_t size)
{
- if (size > size_type(sizeof(data_)))
+ if (size > sizeof(data_))
{
boost::system::system_error e(boost::asio::error::invalid_argument);
boost::throw_exception(e);
@@ -210,7 +202,7 @@
}
/// Get the capacity of the endpoint in the native type.
- size_type capacity() const
+ std::size_t capacity() const
{
return sizeof(data_);
}
Modified: trunk/boost/asio/ip/basic_resolver_iterator.hpp
==============================================================================
--- trunk/boost/asio/ip/basic_resolver_iterator.hpp (original)
+++ trunk/boost/asio/ip/basic_resolver_iterator.hpp 2007-09-20 18:33:29 EDT (Thu, 20 Sep 2007)
@@ -81,9 +81,7 @@
{
using namespace std; // For memcpy.
typename InternetProtocol::endpoint endpoint;
- endpoint.resize(
- static_cast<boost::asio::detail::socket_addr_len_type>(
- address_info->ai_addrlen));
+ endpoint.resize(static_cast<std::size_t>(address_info->ai_addrlen));
memcpy(endpoint.data(), address_info->ai_addr,
address_info->ai_addrlen);
iter.values_->push_back(
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk