Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
godai0519 committed Mar 26, 2013
2 parents 49b66b9 + b6c0e09 commit 56729bd
Show file tree
Hide file tree
Showing 52 changed files with 1,963 additions and 1,472 deletions.
47 changes: 41 additions & 6 deletions BoostConnect.sln
@@ -1,29 +1,64 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sample", "sample\sample.vcxproj", "{EE6486AA-E297-45E8-BBEB-D54B5FD990DE}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "boostconnect", "include\boostconnect\boostconnect.vcxproj", "{16641C79-954C-4833-80D4-64FDC908700B}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "server", "example\server\server.vcxproj", "{CEE6A21B-6C95-4FF8-9A6D-281DFE42AA2B}"
ProjectSection(ProjectDependencies) = postProject
{16641C79-954C-4833-80D4-64FDC908700B} = {16641C79-954C-4833-80D4-64FDC908700B}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "boostconnect", "include\boostconnect\boostconnect.vcxproj", "{16641C79-954C-4833-80D4-64FDC908700B}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "example", "example", "{085DB4C9-B43F-4A7E-9713-011DD89BE532}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "async_client", "example\client\async_client\async_client.vcxproj", "{57EBC71B-77DA-4FF5-B98E-2DDF2F737D14}"
ProjectSection(ProjectDependencies) = postProject
{16641C79-954C-4833-80D4-64FDC908700B} = {16641C79-954C-4833-80D4-64FDC908700B}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sync_client", "example\client\sync_client\sync_client.vcxproj", "{F5E52272-9867-4F53-A4DF-AA0AE2C91198}"
ProjectSection(ProjectDependencies) = postProject
{16641C79-954C-4833-80D4-64FDC908700B} = {16641C79-954C-4833-80D4-64FDC908700B}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssl_client", "example\ssl_client\ssl_client.vcxproj", "{BB6E1E29-8C8E-49EB-BBDA-3F6AB663CC9B}"
ProjectSection(ProjectDependencies) = postProject
{16641C79-954C-4833-80D4-64FDC908700B} = {16641C79-954C-4833-80D4-64FDC908700B}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EE6486AA-E297-45E8-BBEB-D54B5FD990DE}.Debug|Win32.ActiveCfg = Debug|Win32
{EE6486AA-E297-45E8-BBEB-D54B5FD990DE}.Debug|Win32.Build.0 = Debug|Win32
{EE6486AA-E297-45E8-BBEB-D54B5FD990DE}.Release|Win32.ActiveCfg = Release|Win32
{EE6486AA-E297-45E8-BBEB-D54B5FD990DE}.Release|Win32.Build.0 = Release|Win32
{16641C79-954C-4833-80D4-64FDC908700B}.Debug|Win32.ActiveCfg = Debug|Win32
{16641C79-954C-4833-80D4-64FDC908700B}.Debug|Win32.Build.0 = Debug|Win32
{16641C79-954C-4833-80D4-64FDC908700B}.Release|Win32.ActiveCfg = Release|Win32
{16641C79-954C-4833-80D4-64FDC908700B}.Release|Win32.Build.0 = Release|Win32
{CEE6A21B-6C95-4FF8-9A6D-281DFE42AA2B}.Debug|Win32.ActiveCfg = Debug|Win32
{CEE6A21B-6C95-4FF8-9A6D-281DFE42AA2B}.Debug|Win32.Build.0 = Debug|Win32
{CEE6A21B-6C95-4FF8-9A6D-281DFE42AA2B}.Release|Win32.ActiveCfg = Release|Win32
{CEE6A21B-6C95-4FF8-9A6D-281DFE42AA2B}.Release|Win32.Build.0 = Release|Win32
{57EBC71B-77DA-4FF5-B98E-2DDF2F737D14}.Debug|Win32.ActiveCfg = Debug|Win32
{57EBC71B-77DA-4FF5-B98E-2DDF2F737D14}.Debug|Win32.Build.0 = Debug|Win32
{57EBC71B-77DA-4FF5-B98E-2DDF2F737D14}.Release|Win32.ActiveCfg = Release|Win32
{57EBC71B-77DA-4FF5-B98E-2DDF2F737D14}.Release|Win32.Build.0 = Release|Win32
{F5E52272-9867-4F53-A4DF-AA0AE2C91198}.Debug|Win32.ActiveCfg = Debug|Win32
{F5E52272-9867-4F53-A4DF-AA0AE2C91198}.Debug|Win32.Build.0 = Debug|Win32
{F5E52272-9867-4F53-A4DF-AA0AE2C91198}.Release|Win32.ActiveCfg = Release|Win32
{F5E52272-9867-4F53-A4DF-AA0AE2C91198}.Release|Win32.Build.0 = Release|Win32
{BB6E1E29-8C8E-49EB-BBDA-3F6AB663CC9B}.Debug|Win32.ActiveCfg = Debug|Win32
{BB6E1E29-8C8E-49EB-BBDA-3F6AB663CC9B}.Debug|Win32.Build.0 = Debug|Win32
{BB6E1E29-8C8E-49EB-BBDA-3F6AB663CC9B}.Release|Win32.ActiveCfg = Release|Win32
{BB6E1E29-8C8E-49EB-BBDA-3F6AB663CC9B}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{CEE6A21B-6C95-4FF8-9A6D-281DFE42AA2B} = {085DB4C9-B43F-4A7E-9713-011DD89BE532}
{57EBC71B-77DA-4FF5-B98E-2DDF2F737D14} = {085DB4C9-B43F-4A7E-9713-011DD89BE532}
{F5E52272-9867-4F53-A4DF-AA0AE2C91198} = {085DB4C9-B43F-4A7E-9713-011DD89BE532}
{BB6E1E29-8C8E-49EB-BBDA-3F6AB663CC9B} = {085DB4C9-B43F-4A7E-9713-011DD89BE532}
EndGlobalSection
EndGlobal
89 changes: 89 additions & 0 deletions example/client/async_client/async_client.cpp
@@ -0,0 +1,89 @@
#include <iostream>
#include <boostconnect/connection_type/async_connection.hpp>
#include <boostconnect/client.hpp>

int main()
{
typedef boost::system::error_code error_code;
typedef bstcon::client::response_type response_type; // = boost::shared_ptr<bstcon::response>
typedef bstcon::client::connection_ptr connection_ptr;

// Make: request header and body
boost::shared_ptr<boost::asio::streambuf> request_keep(new boost::asio::streambuf());
{
std::ostream os(request_keep.get());
os << "GET / HTTP/1.1\r\n";
os << "Host: www.google.co.jp\r\n";
os << "Connection: Keep-Alive\r\n";
os << "\r\n";
}
boost::shared_ptr<boost::asio::streambuf> request_close(new boost::asio::streambuf());
{
std::ostream os(request_close.get());
os << "GET / HTTP/1.1\r\n";
os << "Host: www.google.co.jp\r\n";
os << "Connection: close\r\n";
os << "\r\n";
}

// Make: client using async
boost::asio::io_service io_service;
bstcon::client client(
io_service,
bstcon::connection_type::async // important!
);

// Challenge TCP connection establishment
bstcon::client::connection_ptr connection = client(
std::string("www.google.co.jp"),
[&](bstcon::client::connection_ptr connection_inner, boost::system::error_code ec)->void // Callback
{
assert(connection == connection_inner); // guarantee that

if(ec)
{
// Bad connection
throw;
}

// Nested lambda
auto connection_ = connection;
auto request_close_ = request_close;

// Send First request
connection->send(
request_keep,
[connection_, request_close_](response_type response, boost::system::error_code ec)->void // Callback
{
if(ec && ec != boost::asio::error::eof)
{
// can't send request or read response
throw;
}

// Show first response
std::cout << "Status Code: " << response->status_code << " " << response->status_message << std::endl;
std::cout << response->body + "\n\n" <<std::endl;

// Send Second request (Continue request)
connection_->send(
request_close_,
[](bstcon::client::response_type response, boost::system::error_code ec)->void // Callback
{
if(ec && ec != boost::asio::error::eof) throw;

// Show second response
std::cout << "Status Code: " << response->status_code << " " << response->status_message << std::endl;
std::cout << response->body + "\n\n" << std::endl;
}
);
}
);
}
);

// Run the above
io_service.run();

return 0;
}
79 changes: 79 additions & 0 deletions example/client/async_client/async_client.vcxproj
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="async_client.cpp" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{57EBC71B-77DA-4FF5-B98E-2DDF2F737D14}</ProjectGuid>
<RootNamespace>Samples</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v100</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IncludePath>C:\openssl\build\debug\include;C:\boost\include\boost-1_52;$(SolutionDir)include;$(IncludePath)</IncludePath>
<LibraryPath>$(SolutionDir)lib;C:\openssl\build\debug\lib;C:\boost\lib;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IncludePath>C:\openssl\build\debug\include;C:\boost\include\boost-1_52;$(ProjectDir)..\include;$(IncludePath)</IncludePath>
<LibraryPath>$(SolutionDir)lib;C:\openssl\build\debug\lib;C:\boost\lib;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<DisableLanguageExtensions>false</DisableLanguageExtensions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>ssleay32.lib;libeay32.lib;libboostconnect_d.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>ssleay32.lib;libeay32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
22 changes: 22 additions & 0 deletions example/client/async_client/async_client.vcxproj.filters
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="ソース ファイル">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="ヘッダー ファイル">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="リソース ファイル">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="async_client.cpp">
<Filter>ソース ファイル</Filter>
</ClCompile>
</ItemGroup>
</Project>
File renamed without changes.
76 changes: 76 additions & 0 deletions example/client/sync_client/sync_client.cpp
@@ -0,0 +1,76 @@
#include <iostream>
#include <boostconnect/connection_type/async_connection.hpp>
#include <boostconnect/client.hpp>

int main()
{
typedef boost::system::error_code error_code;
typedef bstcon::client::response_type response_type; // = boost::shared_ptr<bstcon::response>
typedef bstcon::client::connection_ptr connection_ptr;

// Make: request header and body
boost::shared_ptr<boost::asio::streambuf> request_keep(new boost::asio::streambuf());
{
std::ostream os(request_keep.get());
os << "GET / HTTP/1.1\r\n";
os << "Host: www.google.co.jp\r\n";
os << "Connection: Keep-Alive\r\n";
os << "\r\n";
}
boost::shared_ptr<boost::asio::streambuf> request_close(new boost::asio::streambuf());
{
std::ostream os(request_close.get());
os << "GET / HTTP/1.1\r\n";
os << "Host: www.google.co.jp\r\n";
os << "Connection: close\r\n";
os << "\r\n";
}

// Make: client using sync
boost::asio::io_service io_service;
bstcon::client client(
io_service,
bstcon::connection_type::sync // important!
);

// Challenge TCP connection establishment
connection_ptr connection = client(
std::string("www.google.co.jp"),
[](bstcon::client::connection_ptr connection_inner, boost::system::error_code ec)->void
{
if(ec) throw; // Bad connection
}
);

// Send First request
connection->send(
request_keep,
[](response_type response, boost::system::error_code ec)->void // Callback
{
if(ec && ec != boost::asio::error::eof) throw; // can't send request or read response

// Show first response
std::cout << "Status Code: " << response->status_code << " " << response->status_message << std::endl;
std::cout << response->body + "\n\n" <<std::endl;

});

//
// --- Connection Keeping ---
//

// Send Second request (Continue request)
connection->send(
request_close,
[](bstcon::client::response_type response, boost::system::error_code ec)->void // Callback
{
if(ec && ec != boost::asio::error::eof) throw; // can't send request or read response

// Show second response
std::cout << "Status Code: " << response->status_code << " " << response->status_message << std::endl;
std::cout << response->body + "\n\n" << std::endl;
}
);

return 0;
}
Expand Up @@ -10,15 +10,19 @@
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="sync_client.cpp" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{EE6486AA-E297-45E8-BBEB-D54B5FD990DE}</ProjectGuid>
<ProjectGuid>{F5E52272-9867-4F53-A4DF-AA0AE2C91198}</ProjectGuid>
<RootNamespace>Samples</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v100</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
Expand All @@ -37,7 +41,7 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IncludePath>C:\openssl\build\debug\include;C:\boost\include\boost-1_52;$(ProjectDir)..\include;$(IncludePath)</IncludePath>
<IncludePath>C:\openssl\build\debug\include;C:\boost\include\boost-1_52;$(SolutionDir)include;$(IncludePath)</IncludePath>
<LibraryPath>$(SolutionDir)lib;C:\openssl\build\debug\lib;C:\boost\lib;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
Expand Down Expand Up @@ -69,9 +73,6 @@
<AdditionalDependencies>ssleay32.lib;libeay32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="sample.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down

0 comments on commit 56729bd

Please sign in to comment.