forked from ldcsaa/HP-Socket
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
liangdc
committed
Jul 1, 2016
1 parent
61cd69d
commit 3290c81
Showing
777 changed files
with
60,181 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Hp_Socket.fne 放入易语言Lib目录 | ||
Hp_Socket_static.lib、HPSocket_4C.lib 放入static_Lib目录 | ||
|
||
本支持库需要易语言vs2010链接器(链接: http://pan.baidu.com/s/1i3ydamT 密码: baka) | ||
|
||
点击链接加入群【怪兽乐园】:http://jq.qq.com/?_wv=1027&k=2Ia8fHv | ||
|
||
3.5.1 相对于其他版本变动 | ||
1.删除AddressInfo 数据类型 |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
�����ȳ�ʼ��ģ�飡�������� |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
* C# SDK ���ߣ� int 2e | ||
* ������֧�ֿ� ���ߣ� Yecate | ||
* ������ģ�� ���ߣ� Խ��άС�� | ||
|
||
1��C# Demo ���ߣ� int 2e | ||
2��Delphi Demo ���ߣ� �����д~ | ||
3�������� Demo ���ߣ� Yecate��Խ��άС�� |
246 changes: 246 additions & 0 deletions
246
HP-Socket/Demo/Other Languages Demos/C#/HPSocket4CS/HPSocketCS.sln
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
102 changes: 102 additions & 0 deletions
102
HP-Socket/Demo/Other Languages Demos/C#/HPSocket4CS/HPSocketCS/HPSocketCS.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProductVersion>8.0.30703</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{DFA935E2-CF37-4E26-B697-D7F3DEE19DD8}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>HPSocketCS</RootNamespace> | ||
<AssemblyName>HPSocketCS</AssemblyName> | ||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>..\bin\x86\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>..\bin\x86\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> | ||
<DebugSymbols>true</DebugSymbols> | ||
<OutputPath>..\bin\x64\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<DebugType>full</DebugType> | ||
<PlatformTarget>x64</PlatformTarget> | ||
<CodeAnalysisLogFile>..\bin\Debug\HPSocketCS.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile> | ||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression> | ||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile> | ||
<ErrorReport>prompt</ErrorReport> | ||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> | ||
<CodeAnalysisRuleSetDirectories>;D:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories> | ||
<CodeAnalysisRuleDirectories>;D:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> | ||
<OutputPath>..\bin\x64\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<Optimize>true</Optimize> | ||
<DebugType>pdbonly</DebugType> | ||
<PlatformTarget>x64</PlatformTarget> | ||
<CodeAnalysisLogFile>..\bin\Release\HPSocketCS.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile> | ||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression> | ||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile> | ||
<ErrorReport>prompt</ErrorReport> | ||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> | ||
<CodeAnalysisRuleSetDirectories>;D:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories> | ||
<CodeAnalysisRuleDirectories>;D:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Sdk.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="SSLClient.cs" /> | ||
<Compile Include="SSLSdk.cs" /> | ||
<Compile Include="SSLServer.cs" /> | ||
<Compile Include="SSLAgent.cs" /> | ||
<Compile Include="TcpAgent.cs" /> | ||
<Compile Include="SSLPackServer.cs" /> | ||
<Compile Include="SSLPackClient.cs" /> | ||
<Compile Include="SSLPackAgent.cs" /> | ||
<Compile Include="TcpPackServer.cs" /> | ||
<Compile Include="SSLPullAgent.cs" /> | ||
<Compile Include="TcpPullAgent.cs" /> | ||
<Compile Include="TcpClient.cs" /> | ||
<Compile Include="SSLPullClient.cs" /> | ||
<Compile Include="TcpPullClient.cs" /> | ||
<Compile Include="SSLPullServer.cs" /> | ||
<Compile Include="TcpServer.cs" /> | ||
<Compile Include="TcpPullServer.cs" /> | ||
<Compile Include="TcpPackAgent.cs" /> | ||
<Compile Include="TcpPackClient.cs" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
36 changes: 36 additions & 0 deletions
36
HP-Socket/Demo/Other Languages Demos/C#/HPSocket4CS/HPSocketCS/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// 有关程序集的常规信息通过以下 | ||
// 特性集控制。更改这些特性值可修改 | ||
// 与程序集关联的信息。 | ||
[assembly: AssemblyTitle("HPSocketCS")] | ||
[assembly: AssemblyDescription("HP-Socket for C#")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("JessMA Open Source")] | ||
[assembly: AssemblyProduct("HPSocketCS")] | ||
[assembly: AssemblyCopyright("Copyright © 2016")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// 将 ComVisible 设置为 false 使此程序集中的类型 | ||
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, | ||
// 则将该类型上的 ComVisible 特性设置为 true。 | ||
[assembly: ComVisible(false)] | ||
|
||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID | ||
[assembly: Guid("f54bd34d-cd0c-40dc-8c50-73c3ead0a894")] | ||
|
||
// 程序集的版本信息由下面四个值组成: | ||
// | ||
// 主版本 | ||
// 次版本 | ||
// 内部版本号 | ||
// 修订号 | ||
// | ||
// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, | ||
// 方法是按如下所示使用“*”: | ||
|
||
[assembly: AssemblyVersion("3.5.2")] | ||
[assembly: AssemblyFileVersion("3.5.2")] |
202 changes: 202 additions & 0 deletions
202
HP-Socket/Demo/Other Languages Demos/C#/HPSocket4CS/HPSocketCS/SSLAgent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Runtime.InteropServices; | ||
using System.Runtime.Serialization; | ||
using System.Runtime.Serialization.Formatters.Binary; | ||
using System.Linq; | ||
using System.Text; | ||
using System.IO; | ||
using System.Threading; | ||
|
||
namespace HPSocketCS | ||
{ | ||
public class SSLAgent : TcpAgent | ||
{ | ||
static int ObjectReferer = 0; | ||
static string SSLInitLock = "SSL初始化锁"; | ||
Sdk.OnHandShake _OnHandShake = null; | ||
|
||
/// <summary> | ||
/// 验证模式 | ||
/// </summary> | ||
public SSLVerifyMode VerifyMode { get; set; } | ||
/// <summary> | ||
/// 证书文件(客户端可选) | ||
/// </summary> | ||
public string PemCertFile { get; set; } | ||
/// <summary> | ||
/// 私钥文件(客户端可选) | ||
/// </summary> | ||
public string PemKeyFile { get; set; } | ||
/// <summary> | ||
/// 私钥密码(没有密码则为空) | ||
/// </summary> | ||
public string KeyPasswod { get; set; } | ||
/// <summary> | ||
/// CA 证书文件或目录(单向验证或客户端可选) | ||
/// </summary> | ||
public string CAPemCertFileOrPath { get; set; } | ||
|
||
|
||
/// <summary> | ||
/// SSL握手成功事件 | ||
/// </summary> | ||
public event SSLEvent.OnHandShakeEventHandler OnHandShake; | ||
|
||
public SSLAgent() | ||
{ | ||
Interlocked.Increment(ref ObjectReferer); | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="_verifyModel">验证模式</param> | ||
/// <param name="_pemCertFile">证书文件</param> | ||
/// <param name="_pemKeyFile">私钥文件</param> | ||
/// <param name="_keyPasswod">私钥密码(没有密码则为空)</param> | ||
/// <param name="_caPemCertFileOrPath">CA 证书文件或目录(单向验证或客户端可选)</param> | ||
public SSLAgent(SSLVerifyMode _verifyModel, string _pemCertFile, string _pemKeyFile, string _keyPasswod, string _caPemCertFileOrPath) | ||
{ | ||
Interlocked.Increment(ref ObjectReferer); | ||
this.VerifyMode = _verifyModel; | ||
this.PemCertFile = _pemCertFile; | ||
this.PemKeyFile = _pemKeyFile; | ||
this.KeyPasswod = _keyPasswod; | ||
this.CAPemCertFileOrPath = _caPemCertFileOrPath; | ||
Initialize(); | ||
} | ||
|
||
~SSLAgent() | ||
{ | ||
Uninitialize(); | ||
} | ||
|
||
protected override bool CreateListener() | ||
{ | ||
if (IsCreate == true || pListener != IntPtr.Zero || pAgent != IntPtr.Zero) | ||
{ | ||
return false; | ||
} | ||
|
||
pListener = Sdk.Create_HP_TcpAgentListener(); | ||
if (pListener == IntPtr.Zero) | ||
{ | ||
return false; | ||
} | ||
|
||
pAgent = SSLSdk.Create_HP_SSLAgent(pListener); | ||
if (pAgent == IntPtr.Zero) | ||
{ | ||
return false; | ||
} | ||
|
||
IsCreate = true; | ||
|
||
return true; | ||
} | ||
|
||
protected override void SetCallback() | ||
{ | ||
_OnHandShake = new Sdk.OnHandShake(SDK_OnHandShake); | ||
Sdk.HP_Set_FN_Server_OnHandShake(pListener, _OnHandShake); | ||
base.SetCallback(); | ||
} | ||
|
||
/// <summary> | ||
/// 初始化SSL环境 | ||
/// </summary> | ||
/// <returns></returns> | ||
protected virtual bool Initialize() | ||
{ | ||
lock (SSLInitLock) | ||
{ | ||
if (SSLSdk.HP_SSL_IsValid() == false) | ||
{ | ||
if (string.IsNullOrWhiteSpace(PemCertFile)) | ||
{ | ||
throw new NullReferenceException("PemCertFile"); | ||
} | ||
|
||
if (string.IsNullOrWhiteSpace(PemKeyFile)) | ||
{ | ||
throw new NullReferenceException("PemKeyFile"); | ||
} | ||
|
||
if (string.IsNullOrWhiteSpace(KeyPasswod)) | ||
{ | ||
throw new NullReferenceException("KeyPasswod"); | ||
} | ||
|
||
if (string.IsNullOrWhiteSpace(CAPemCertFileOrPath)) | ||
{ | ||
throw new NullReferenceException("CAPemCertFileOrPath"); | ||
} | ||
|
||
return SSLSdk.HP_SSL_Initialize(SSLSessionMode.Client, VerifyMode, PemCertFile, PemKeyFile, KeyPasswod, CAPemCertFileOrPath); | ||
|
||
} | ||
|
||
return true; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// 反初始化SSL环境 | ||
/// </summary> | ||
protected virtual void Uninitialize() | ||
{ | ||
if (Interlocked.Decrement(ref ObjectReferer) == 0) | ||
{ | ||
SSLSdk.HP_SSL_Cleanup(); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// 启动通讯组件 | ||
/// 启动完成后可开始连接远程服务器 | ||
/// </summary> | ||
/// <param name="address">绑定地址</param> | ||
/// <param name="async">是否异步</param> | ||
/// <returns></returns> | ||
public new bool Start(string address, bool async = false) | ||
{ | ||
bool ret = false; | ||
if (Initialize()) | ||
{ | ||
ret = base.Start(address, async); | ||
} | ||
|
||
return ret; | ||
} | ||
|
||
|
||
public override void Destroy() | ||
{ | ||
|
||
Stop(); | ||
|
||
if (pAgent != IntPtr.Zero) | ||
{ | ||
SSLSdk.Destroy_HP_SSLAgent(pAgent); | ||
pAgent = IntPtr.Zero; | ||
} | ||
if (pListener != IntPtr.Zero) | ||
{ | ||
Sdk.Destroy_HP_TcpAgentListener(pListener); | ||
pListener = IntPtr.Zero; | ||
} | ||
|
||
IsCreate = false; | ||
} | ||
|
||
protected HandleResult SDK_OnHandShake(IntPtr connId) | ||
{ | ||
if (OnHandShake != null) | ||
{ | ||
return OnHandShake(connId); | ||
} | ||
return HandleResult.Ignore; | ||
} | ||
} | ||
} |
Oops, something went wrong.