@ -0,0 +1,23 @@ | |||||
| |||||
#include <iostream> | |||||
#include<event2/event.h> | |||||
int main() | |||||
{ | |||||
#ifdef _WIN32 | |||||
//初始化socket库 | |||||
WSADATA wsa; | |||||
WSAStartup(MAKEWORD(2, 2), &wsa); | |||||
#endif | |||||
std::cout << "test libevent!\n"; | |||||
//创建libevent上下文 | |||||
event_base* base = event_base_new(); | |||||
if (base) { | |||||
std::cout << "yes"; | |||||
} | |||||
return 0; | |||||
} | |||||
@ -0,0 +1,31 @@ | |||||
| |||||
Microsoft Visual Studio Solution File, Format Version 12.00 | |||||
# Visual Studio 15 | |||||
VisualStudioVersion = 15.0.28307.1525 | |||||
MinimumVisualStudioVersion = 10.0.40219.1 | |||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "first_libevent", "first_libevent.vcxproj", "{129BF326-BFEE-4F1C-920C-0C302BB84895}" | |||||
EndProject | |||||
Global | |||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | |||||
Debug|x64 = Debug|x64 | |||||
Debug|x86 = Debug|x86 | |||||
Release|x64 = Release|x64 | |||||
Release|x86 = Release|x86 | |||||
EndGlobalSection | |||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | |||||
{129BF326-BFEE-4F1C-920C-0C302BB84895}.Debug|x64.ActiveCfg = Debug|x64 | |||||
{129BF326-BFEE-4F1C-920C-0C302BB84895}.Debug|x64.Build.0 = Debug|x64 | |||||
{129BF326-BFEE-4F1C-920C-0C302BB84895}.Debug|x86.ActiveCfg = Debug|Win32 | |||||
{129BF326-BFEE-4F1C-920C-0C302BB84895}.Debug|x86.Build.0 = Debug|Win32 | |||||
{129BF326-BFEE-4F1C-920C-0C302BB84895}.Release|x64.ActiveCfg = Release|x64 | |||||
{129BF326-BFEE-4F1C-920C-0C302BB84895}.Release|x64.Build.0 = Release|x64 | |||||
{129BF326-BFEE-4F1C-920C-0C302BB84895}.Release|x86.ActiveCfg = Release|Win32 | |||||
{129BF326-BFEE-4F1C-920C-0C302BB84895}.Release|x86.Build.0 = Release|Win32 | |||||
EndGlobalSection | |||||
GlobalSection(SolutionProperties) = preSolution | |||||
HideSolutionNode = FALSE | |||||
EndGlobalSection | |||||
GlobalSection(ExtensibilityGlobals) = postSolution | |||||
SolutionGuid = {191D7F93-7554-493B-92E1-BB302C5A8383} | |||||
EndGlobalSection | |||||
EndGlobal |
@ -0,0 +1,161 @@ | |||||
<?xml version="1.0" encoding="utf-8"?> | |||||
<Project DefaultTargets="Build" ToolsVersion="15.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> | |||||
<ProjectConfiguration Include="Debug|x64"> | |||||
<Configuration>Debug</Configuration> | |||||
<Platform>x64</Platform> | |||||
</ProjectConfiguration> | |||||
<ProjectConfiguration Include="Release|x64"> | |||||
<Configuration>Release</Configuration> | |||||
<Platform>x64</Platform> | |||||
</ProjectConfiguration> | |||||
</ItemGroup> | |||||
<PropertyGroup Label="Globals"> | |||||
<VCProjectVersion>15.0</VCProjectVersion> | |||||
<ProjectGuid>{129BF326-BFEE-4F1C-920C-0C302BB84895}</ProjectGuid> | |||||
<Keyword>Win32Proj</Keyword> | |||||
<RootNamespace>firstlibevent</RootNamespace> | |||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion> | |||||
</PropertyGroup> | |||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | |||||
<ConfigurationType>Application</ConfigurationType> | |||||
<UseDebugLibraries>true</UseDebugLibraries> | |||||
<PlatformToolset>v141</PlatformToolset> | |||||
<CharacterSet>Unicode</CharacterSet> | |||||
</PropertyGroup> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | |||||
<ConfigurationType>Application</ConfigurationType> | |||||
<UseDebugLibraries>false</UseDebugLibraries> | |||||
<PlatformToolset>v141</PlatformToolset> | |||||
<WholeProgramOptimization>true</WholeProgramOptimization> | |||||
<CharacterSet>Unicode</CharacterSet> | |||||
</PropertyGroup> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> | |||||
<ConfigurationType>Application</ConfigurationType> | |||||
<UseDebugLibraries>true</UseDebugLibraries> | |||||
<PlatformToolset>v141</PlatformToolset> | |||||
<CharacterSet>Unicode</CharacterSet> | |||||
</PropertyGroup> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | |||||
<ConfigurationType>Application</ConfigurationType> | |||||
<UseDebugLibraries>false</UseDebugLibraries> | |||||
<PlatformToolset>v141</PlatformToolset> | |||||
<WholeProgramOptimization>true</WholeProgramOptimization> | |||||
<CharacterSet>Unicode</CharacterSet> | |||||
</PropertyGroup> | |||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | |||||
<ImportGroup Label="ExtensionSettings"> | |||||
</ImportGroup> | |||||
<ImportGroup Label="Shared"> | |||||
</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> | |||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | |||||
<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|x64'"> | |||||
<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'"> | |||||
<LinkIncremental>true</LinkIncremental> | |||||
</PropertyGroup> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | |||||
<LinkIncremental>true</LinkIncremental> | |||||
</PropertyGroup> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | |||||
<LinkIncremental>false</LinkIncremental> | |||||
</PropertyGroup> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | |||||
<LinkIncremental>false</LinkIncremental> | |||||
</PropertyGroup> | |||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | |||||
<ClCompile> | |||||
<PrecompiledHeader> | |||||
</PrecompiledHeader> | |||||
<WarningLevel>Level3</WarningLevel> | |||||
<Optimization>Disabled</Optimization> | |||||
<SDLCheck>true</SDLCheck> | |||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |||||
<ConformanceMode>true</ConformanceMode> | |||||
</ClCompile> | |||||
<Link> | |||||
<SubSystem>Console</SubSystem> | |||||
<GenerateDebugInformation>true</GenerateDebugInformation> | |||||
</Link> | |||||
</ItemDefinitionGroup> | |||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | |||||
<ClCompile> | |||||
<PrecompiledHeader>NotUsing</PrecompiledHeader> | |||||
<WarningLevel>Level3</WarningLevel> | |||||
<Optimization>Disabled</Optimization> | |||||
<SDLCheck>true</SDLCheck> | |||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |||||
<ConformanceMode>true</ConformanceMode> | |||||
<AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories> | |||||
</ClCompile> | |||||
<Link> | |||||
<SubSystem>Console</SubSystem> | |||||
<GenerateDebugInformation>true</GenerateDebugInformation> | |||||
<AdditionalLibraryDirectories>..\..\lib</AdditionalLibraryDirectories> | |||||
<AdditionalDependencies>libevent.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies> | |||||
</Link> | |||||
</ItemDefinitionGroup> | |||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | |||||
<ClCompile> | |||||
<PrecompiledHeader> | |||||
</PrecompiledHeader> | |||||
<WarningLevel>Level3</WarningLevel> | |||||
<Optimization>MaxSpeed</Optimization> | |||||
<FunctionLevelLinking>true</FunctionLevelLinking> | |||||
<IntrinsicFunctions>true</IntrinsicFunctions> | |||||
<SDLCheck>true</SDLCheck> | |||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |||||
<ConformanceMode>true</ConformanceMode> | |||||
</ClCompile> | |||||
<Link> | |||||
<SubSystem>Console</SubSystem> | |||||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | |||||
<OptimizeReferences>true</OptimizeReferences> | |||||
<GenerateDebugInformation>true</GenerateDebugInformation> | |||||
</Link> | |||||
</ItemDefinitionGroup> | |||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | |||||
<ClCompile> | |||||
<PrecompiledHeader> | |||||
</PrecompiledHeader> | |||||
<WarningLevel>Level3</WarningLevel> | |||||
<Optimization>MaxSpeed</Optimization> | |||||
<FunctionLevelLinking>true</FunctionLevelLinking> | |||||
<IntrinsicFunctions>true</IntrinsicFunctions> | |||||
<SDLCheck>true</SDLCheck> | |||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |||||
<ConformanceMode>true</ConformanceMode> | |||||
</ClCompile> | |||||
<Link> | |||||
<SubSystem>Console</SubSystem> | |||||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | |||||
<OptimizeReferences>true</OptimizeReferences> | |||||
<GenerateDebugInformation>true</GenerateDebugInformation> | |||||
</Link> | |||||
</ItemDefinitionGroup> | |||||
<ItemGroup> | |||||
<ClCompile Include="first_libevent.cpp" /> | |||||
</ItemGroup> | |||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | |||||
<ImportGroup Label="ExtensionTargets"> | |||||
</ImportGroup> | |||||
</Project> |
@ -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;hh;hpp;hxx;hm;inl;inc;ipp;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="first_libevent.cpp"> | |||||
<Filter>源文件</Filter> | |||||
</ClCompile> | |||||
</ItemGroup> | |||||
</Project> |
@ -0,0 +1,4 @@ | |||||
<?xml version="1.0" encoding="utf-8"?> | |||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||||
<PropertyGroup /> | |||||
</Project> |
@ -0,0 +1,2 @@ | |||||
first_libevent.cpp | |||||
first_libevent.vcxproj -> D:\c++\lib\libevent\src\first_libevent\x64\Debug\first_libevent.exe |
@ -0,0 +1,2 @@ | |||||
#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0 | |||||
Debug|x64|D:\c++\lib\libevent\src\first_libevent\| |
@ -0,0 +1,31 @@ | |||||
| |||||
Microsoft Visual Studio Solution File, Format Version 12.00 | |||||
# Visual Studio 15 | |||||
VisualStudioVersion = 15.0.28307.1525 | |||||
MinimumVisualStudioVersion = 10.0.40219.1 | |||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "first_libevent", "first_libevent.vcxproj", "{129BF326-BFEE-4F1C-920C-0C302BB84895}" | |||||
EndProject | |||||
Global | |||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | |||||
Debug|x64 = Debug|x64 | |||||
Debug|x86 = Debug|x86 | |||||
Release|x64 = Release|x64 | |||||
Release|x86 = Release|x86 | |||||
EndGlobalSection | |||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | |||||
{129BF326-BFEE-4F1C-920C-0C302BB84895}.Debug|x64.ActiveCfg = Debug|x64 | |||||
{129BF326-BFEE-4F1C-920C-0C302BB84895}.Debug|x64.Build.0 = Debug|x64 | |||||
{129BF326-BFEE-4F1C-920C-0C302BB84895}.Debug|x86.ActiveCfg = Debug|Win32 | |||||
{129BF326-BFEE-4F1C-920C-0C302BB84895}.Debug|x86.Build.0 = Debug|Win32 | |||||
{129BF326-BFEE-4F1C-920C-0C302BB84895}.Release|x64.ActiveCfg = Release|x64 | |||||
{129BF326-BFEE-4F1C-920C-0C302BB84895}.Release|x64.Build.0 = Release|x64 | |||||
{129BF326-BFEE-4F1C-920C-0C302BB84895}.Release|x86.ActiveCfg = Release|Win32 | |||||
{129BF326-BFEE-4F1C-920C-0C302BB84895}.Release|x86.Build.0 = Release|Win32 | |||||
EndGlobalSection | |||||
GlobalSection(SolutionProperties) = preSolution | |||||
HideSolutionNode = FALSE | |||||
EndGlobalSection | |||||
GlobalSection(ExtensibilityGlobals) = postSolution | |||||
SolutionGuid = {191D7F93-7554-493B-92E1-BB302C5A8383} | |||||
EndGlobalSection | |||||
EndGlobal |
@ -0,0 +1,162 @@ | |||||
<?xml version="1.0" encoding="utf-8"?> | |||||
<Project DefaultTargets="Build" ToolsVersion="15.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> | |||||
<ProjectConfiguration Include="Debug|x64"> | |||||
<Configuration>Debug</Configuration> | |||||
<Platform>x64</Platform> | |||||
</ProjectConfiguration> | |||||
<ProjectConfiguration Include="Release|x64"> | |||||
<Configuration>Release</Configuration> | |||||
<Platform>x64</Platform> | |||||
</ProjectConfiguration> | |||||
</ItemGroup> | |||||
<PropertyGroup Label="Globals"> | |||||
<VCProjectVersion>15.0</VCProjectVersion> | |||||
<ProjectGuid>{129BF326-BFEE-4F1C-920C-0C302BB84895}</ProjectGuid> | |||||
<Keyword>Win32Proj</Keyword> | |||||
<RootNamespace>firstlibevent</RootNamespace> | |||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion> | |||||
<ProjectName>test_libevent</ProjectName> | |||||
</PropertyGroup> | |||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | |||||
<ConfigurationType>Application</ConfigurationType> | |||||
<UseDebugLibraries>true</UseDebugLibraries> | |||||
<PlatformToolset>v141</PlatformToolset> | |||||
<CharacterSet>Unicode</CharacterSet> | |||||
</PropertyGroup> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | |||||
<ConfigurationType>Application</ConfigurationType> | |||||
<UseDebugLibraries>false</UseDebugLibraries> | |||||
<PlatformToolset>v141</PlatformToolset> | |||||
<WholeProgramOptimization>true</WholeProgramOptimization> | |||||
<CharacterSet>Unicode</CharacterSet> | |||||
</PropertyGroup> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> | |||||
<ConfigurationType>Application</ConfigurationType> | |||||
<UseDebugLibraries>true</UseDebugLibraries> | |||||
<PlatformToolset>v141</PlatformToolset> | |||||
<CharacterSet>Unicode</CharacterSet> | |||||
</PropertyGroup> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | |||||
<ConfigurationType>Application</ConfigurationType> | |||||
<UseDebugLibraries>false</UseDebugLibraries> | |||||
<PlatformToolset>v141</PlatformToolset> | |||||
<WholeProgramOptimization>true</WholeProgramOptimization> | |||||
<CharacterSet>Unicode</CharacterSet> | |||||
</PropertyGroup> | |||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | |||||
<ImportGroup Label="ExtensionSettings"> | |||||
</ImportGroup> | |||||
<ImportGroup Label="Shared"> | |||||
</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> | |||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | |||||
<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|x64'"> | |||||
<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'"> | |||||
<LinkIncremental>true</LinkIncremental> | |||||
</PropertyGroup> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | |||||
<LinkIncremental>true</LinkIncremental> | |||||
</PropertyGroup> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | |||||
<LinkIncremental>false</LinkIncremental> | |||||
</PropertyGroup> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | |||||
<LinkIncremental>false</LinkIncremental> | |||||
</PropertyGroup> | |||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | |||||
<ClCompile> | |||||
<PrecompiledHeader> | |||||
</PrecompiledHeader> | |||||
<WarningLevel>Level3</WarningLevel> | |||||
<Optimization>Disabled</Optimization> | |||||
<SDLCheck>true</SDLCheck> | |||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |||||
<ConformanceMode>true</ConformanceMode> | |||||
</ClCompile> | |||||
<Link> | |||||
<SubSystem>Console</SubSystem> | |||||
<GenerateDebugInformation>true</GenerateDebugInformation> | |||||
</Link> | |||||
</ItemDefinitionGroup> | |||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | |||||
<ClCompile> | |||||
<PrecompiledHeader>NotUsing</PrecompiledHeader> | |||||
<WarningLevel>Level3</WarningLevel> | |||||
<Optimization>Disabled</Optimization> | |||||
<SDLCheck>true</SDLCheck> | |||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |||||
<ConformanceMode>true</ConformanceMode> | |||||
<AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories> | |||||
</ClCompile> | |||||
<Link> | |||||
<SubSystem>Console</SubSystem> | |||||
<GenerateDebugInformation>true</GenerateDebugInformation> | |||||
<AdditionalLibraryDirectories>..\..\lib</AdditionalLibraryDirectories> | |||||
<AdditionalDependencies>libevent.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies> | |||||
</Link> | |||||
</ItemDefinitionGroup> | |||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | |||||
<ClCompile> | |||||
<PrecompiledHeader> | |||||
</PrecompiledHeader> | |||||
<WarningLevel>Level3</WarningLevel> | |||||
<Optimization>MaxSpeed</Optimization> | |||||
<FunctionLevelLinking>true</FunctionLevelLinking> | |||||
<IntrinsicFunctions>true</IntrinsicFunctions> | |||||
<SDLCheck>true</SDLCheck> | |||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |||||
<ConformanceMode>true</ConformanceMode> | |||||
</ClCompile> | |||||
<Link> | |||||
<SubSystem>Console</SubSystem> | |||||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | |||||
<OptimizeReferences>true</OptimizeReferences> | |||||
<GenerateDebugInformation>true</GenerateDebugInformation> | |||||
</Link> | |||||
</ItemDefinitionGroup> | |||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | |||||
<ClCompile> | |||||
<PrecompiledHeader> | |||||
</PrecompiledHeader> | |||||
<WarningLevel>Level3</WarningLevel> | |||||
<Optimization>MaxSpeed</Optimization> | |||||
<FunctionLevelLinking>true</FunctionLevelLinking> | |||||
<IntrinsicFunctions>true</IntrinsicFunctions> | |||||
<SDLCheck>true</SDLCheck> | |||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |||||
<ConformanceMode>true</ConformanceMode> | |||||
</ClCompile> | |||||
<Link> | |||||
<SubSystem>Console</SubSystem> | |||||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | |||||
<OptimizeReferences>true</OptimizeReferences> | |||||
<GenerateDebugInformation>true</GenerateDebugInformation> | |||||
</Link> | |||||
</ItemDefinitionGroup> | |||||
<ItemGroup> | |||||
<ClCompile Include="test_libevent.cpp" /> | |||||
</ItemGroup> | |||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | |||||
<ImportGroup Label="ExtensionTargets"> | |||||
</ImportGroup> | |||||
</Project> |
@ -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;hh;hpp;hxx;hm;inl;inc;ipp;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="test_libevent.cpp"> | |||||
<Filter>源文件</Filter> | |||||
</ClCompile> | |||||
</ItemGroup> | |||||
</Project> |
@ -0,0 +1,4 @@ | |||||
<?xml version="1.0" encoding="utf-8"?> | |||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||||
<PropertyGroup /> | |||||
</Project> |
@ -0,0 +1,67 @@ | |||||
| |||||
#include <iostream> | |||||
#include<event2/event.h> | |||||
#include <event2/listener.h> | |||||
#include <string.h> | |||||
#ifndef _WIN32 | |||||
#include <signal.h> | |||||
#endif // !_WIN32 | |||||
#define SPORT 5001 | |||||
void listen_cb(struct evconnlistener *, evutil_socket_t, struct sockaddr *, int socklen, void *arg) { | |||||
std::cout << "listen to be" << std::endl; | |||||
} | |||||
int main() | |||||
{ | |||||
#ifdef _WIN32 | |||||
//初始化socket库 | |||||
WSADATA wsa; | |||||
WSAStartup(MAKEWORD(2, 2), &wsa); | |||||
#else | |||||
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) { //忽略管道信号,发送数据给已关闭的socket,会飞掉! | |||||
return 1; | |||||
} | |||||
#endif | |||||
//创建libevent上下文 | |||||
event_base* base = event_base_new(); | |||||
if (base) { | |||||
std::cout << "test server" << "\n"; | |||||
} | |||||
sockaddr_in sin; | |||||
memset(&sin, 0, sizeof(sin)); | |||||
sin.sin_family = AF_INET; | |||||
sin.sin_port = htons(SPORT); | |||||
//socket,bind listen 绑定事件 | |||||
evconnlistener * ev = evconnlistener_new_bind(base, //libevent上下文 | |||||
listen_cb, //接收到连接的回调函数 | |||||
base, //回调函数获取的参数(根据业务来) | |||||
LEV_OPT_REUSEABLE | LEV_OPT_CLOSE_ON_FREE, //地址重用,evconnlistener关闭同时关闭socket | |||||
10, //连接队列大小,对应listen函数参数 | |||||
(sockaddr*)&sin,//绑定的地址和端口 | |||||
sizeof(sin) | |||||
); | |||||
if (base) | |||||
event_base_dispatch(base); //事件分发处理 | |||||
if (ev) | |||||
evconnlistener_free(ev); //清理 | |||||
if (base) | |||||
event_base_free(base); | |||||
#if _WIN32 | |||||
WSACleanup(); | |||||
#endif // _WIN32 | |||||
return 0; | |||||
} | |||||
@ -0,0 +1,3 @@ | |||||
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppBuild.targets(391,5): warning MSB8028: 中间目录(x64\Debug\)包含从另一个项目(first_libevent.vcxproj)共享的文件。 这会导致错误的清除和重新生成行为。 | |||||
test_libevent.cpp | |||||
first_libevent.vcxproj -> D:\c++\lib\libevent\src\test_libevent\x64\Debug\test_libevent.exe |
@ -0,0 +1,2 @@ | |||||
#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0 | |||||
Debug|x64|D:\c++\lib\libevent\src\first_libevent\| |
@ -0,0 +1,2 @@ | |||||
#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0 | |||||
Debug|x64|D:\c++\lib\libevent\src\test_libevent\| |