diff --git a/Builds/VisualStudio2012/beast.vcxproj b/Builds/VisualStudio2012/beast.vcxproj
index cdaea28a8..cdf07854e 100644
--- a/Builds/VisualStudio2012/beast.vcxproj
+++ b/Builds/VisualStudio2012/beast.vcxproj
@@ -82,6 +82,8 @@
+
+
@@ -401,6 +403,13 @@
+
+
+ true
+ true
+ true
+ true
+
diff --git a/Builds/VisualStudio2012/beast.vcxproj.filters b/Builds/VisualStudio2012/beast.vcxproj.filters
index 1f927cb51..21a8498eb 100644
--- a/Builds/VisualStudio2012/beast.vcxproj.filters
+++ b/Builds/VisualStudio2012/beast.vcxproj.filters
@@ -297,6 +297,12 @@
{d7ec873a-d1e7-4341-9d20-a1be8f8ddd88}
+
+ {f73fedee-2efb-431b-9f4f-d2fd405454f6}
+
+
+ {30b0fdfb-02b6-47dd-bdd9-ffc1f57e1f2c}
+
@@ -1251,6 +1257,12 @@
beast\net
+
+ beast
+
+
+ beast\asio
+
@@ -1799,6 +1811,12 @@
beast\net\impl
+
+ beast\asio
+
+
+ beast\asio\impl
+
diff --git a/beast/Asio.h b/beast/Asio.h
new file mode 100644
index 000000000..d4e8c590f
--- /dev/null
+++ b/beast/Asio.h
@@ -0,0 +1,25 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted, provided that the above
+ copyright notice and this permission notice appear in all copies.
+
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+//==============================================================================
+
+#ifndef BEAST_ASIO_H_INCLUDED
+#define BEAST_ASIO_H_INCLUDED
+
+#include "asio/IPAddressConversion.h"
+
+#endif
diff --git a/beast/asio/Asio.cpp b/beast/asio/Asio.cpp
new file mode 100644
index 000000000..5aa88c74a
--- /dev/null
+++ b/beast/asio/Asio.cpp
@@ -0,0 +1,22 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted, provided that the above
+ copyright notice and this permission notice appear in all copies.
+
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+//==============================================================================
+
+#include "BeastConfig.h"
+
+#include "impl/IPAddressConversion.cpp"
diff --git a/beast/asio/IPAddressConversion.h b/beast/asio/IPAddressConversion.h
new file mode 100644
index 000000000..0776e4c30
--- /dev/null
+++ b/beast/asio/IPAddressConversion.h
@@ -0,0 +1,50 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted, provided that the above
+ copyright notice and this permission notice appear in all copies.
+
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+//==============================================================================
+
+#ifndef BEAST_ASIO_IPADDRESSCONVERSION_H_INCLUDED
+#define BEAST_ASIO_IPADDRESSCONVERSION_H_INCLUDED
+
+#include "../net/IPAddress.h"
+
+#include
+
+namespace beast {
+
+struct IPAddressConversion
+{
+ /** Convert to IPAddress.
+ The port is set to zero.
+ */
+ static IPAddress from_asio (boost::asio::ip::address const& address);
+
+ /** Convert to IPAddress, including port. */
+ static IPAddress from_asio (boost::asio::ip::tcp::endpoint const& endpoint);
+
+ /** Convert to asio::ip::address.
+ The port is ignored.
+ */
+ static boost::asio::ip::address to_asio_address (IPAddress const& address);
+
+ /** Convert to asio::ip::tcp::endpoint. */
+ static boost::asio::ip::tcp::endpoint to_asio_endpoint (IPAddress const& address);
+};
+
+}
+
+#endif
diff --git a/beast/asio/impl/IPAddressConversion.cpp b/beast/asio/impl/IPAddressConversion.cpp
new file mode 100644
index 000000000..32c8cba86
--- /dev/null
+++ b/beast/asio/impl/IPAddressConversion.cpp
@@ -0,0 +1,65 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted, provided that the above
+ copyright notice and this permission notice appear in all copies.
+
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+//==============================================================================
+
+#include "../IPAddressConversion.h"
+
+namespace beast {
+
+IPAddress IPAddressConversion::from_asio (boost::asio::ip::address const& address)
+{
+ if (address.is_v4 ())
+ {
+ boost::asio::ip::address_v4::bytes_type const bytes (
+ address.to_v4().to_bytes());
+ return IPAddress (IPAddress::V4 (
+ bytes [0], bytes [1], bytes [2], bytes [3]));
+ }
+
+ // VFALCO TODO IPv6 support
+ bassertfalse;
+ return IPAddress();
+}
+
+IPAddress IPAddressConversion::from_asio (boost::asio::ip::tcp::endpoint const& endpoint)
+{
+ return from_asio (endpoint.address()).withPort (endpoint.port());
+}
+
+boost::asio::ip::address IPAddressConversion::to_asio_address (IPAddress const& address)
+{
+ if (address.isV4 ())
+ {
+ return boost::asio::ip::address (
+ boost::asio::ip::address_v4 (
+ address.v4().value));
+ }
+
+ // VFALCO TODO IPv6 support
+ bassertfalse;
+ return boost::asio::ip::address (
+ boost::asio::ip::address_v6 ());
+}
+
+boost::asio::ip::tcp::endpoint IPAddressConversion::to_asio_endpoint (IPAddress const& address)
+{
+ return boost::asio::ip::tcp::endpoint (
+ to_asio_address (address), address.port());
+}
+
+}
diff --git a/modules/beast_asio/beast_asio.h b/modules/beast_asio/beast_asio.h
index f66d966e2..0fd6b21b4 100644
--- a/modules/beast_asio/beast_asio.h
+++ b/modules/beast_asio/beast_asio.h
@@ -17,8 +17,8 @@
*/
//==============================================================================
-#ifndef BEAST_ASIO_H_INCLUDED
-#define BEAST_ASIO_H_INCLUDED
+#ifndef BEAST_ASIO_MODULE_H_INCLUDED
+#define BEAST_ASIO_MODULE_H_INCLUDED
//------------------------------------------------------------------------------
@@ -53,6 +53,7 @@
# define BEAST_SOCKET_VIRTUAL
#endif
+#include "../../beast/Asio.h"
#include "../../beast/MPL.h"
#include "../../beast/Utility.h"
#include "../../beast/HTTP.h"