Skip to content

Commit 370befa

Browse files
author
liangdongcheng
committed
20181203
1 parent b2bfcf9 commit 370befa

File tree

1,239 files changed

+292224
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,239 files changed

+292224
-0
lines changed

Doc/Basic Component.jpg

374 KB
Loading

Doc/Example.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#include <hpsocket/HPSocket4C.h>
2+
3+
// 5. process network events
4+
EnHandleResult __HP_CALL OnConnect(HP_Agent pSender, HP_CONNID dwConnID);
5+
EnHandleResult __HP_CALL OnReceive(HP_Agent pSender, HP_CONNID dwConnID, int iLength);
6+
EnHandleResult __HP_CALL OnSend(HP_Agent pSender, HP_CONNID dwConnID, const BYTE* pData, int iLength);
7+
EnHandleResult __HP_CALL OnClose(HP_Agent pSender, HP_CONNID dwConnID, En_HP_SocketOperation enOperation, int iErrorCode);
8+
EnHandleResult __HP_CALL OnShutdown(HP_Agent pSender);
9+
10+
int main(int argc, char* const argv[])
11+
{
12+
HP_TcpPullAgentListener s_listener;
13+
HP_TcpPullAgent s_agent;
14+
15+
// 1. Create listener object
16+
s_listener = ::Create_HP_TcpPullAgentListener();
17+
// 2. Create component object (and binding with listener object)
18+
s_agent = ::Create_HP_TcpPullAgent(s_listener);
19+
20+
/* Set listener callbacks */
21+
::HP_Set_FN_Agent_OnConnect(s_listener, OnConnect);
22+
::HP_Set_FN_Agent_OnSend(s_listener, OnSend);
23+
::HP_Set_FN_Agent_OnPullReceive(s_listener, OnReceive);
24+
::HP_Set_FN_Agent_OnClose(s_listener, OnClose);
25+
::HP_Set_FN_Agent_OnShutdown(s_listener, OnShutdown);
26+
27+
// 3. Start component object
28+
if(::HP_Agent_HasStarted(s_agent))
29+
exit(1);
30+
31+
// 4. Connect to dest host
32+
::HP_Agent_Connect(s_agent, "remote.host.1", REMOTE_PORT_1, nullptr);
33+
::HP_Agent_Connect(s_agent, "remote.host.2", REMOTE_PORT_2, nullptr);
34+
::HP_Agent_Connect(s_agent, "remote.host.3", REMOTE_PORT_3, nullptr);
35+
36+
/* wait for exit */
37+
// ... ...
38+
39+
// 6. (optional) Stop component object
40+
::HP_Agent_Stop(s_agent)
41+
42+
// 7. Destroy component object
43+
::Destroy_HP_TcpPullAgent(s_agent);
44+
// 8. Destroy listener object
45+
::Destroy_HP_TcpPullAgentListener(s_listener);
46+
47+
return 0;
48+
}

Doc/Example.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include <hpsocket/HPSocket.h>
2+
3+
/* Listener Class */
4+
class CListenerImpl : public CTcpPullServerListener
5+
{
6+
7+
public:
8+
// 5. process network events
9+
virtual EnHandleResult OnPrepareListen(ITcpServer* pSender, SOCKET soListen);
10+
virtual EnHandleResult OnAccept(ITcpServer* pSender, CONNID dwConnID, UINT_PTR soClient);
11+
virtual EnHandleResult OnHandShake(ITcpServer* pSender, CONNID dwConnID);
12+
virtual EnHandleResult OnReceive(ITcpServer* pSender, CONNID dwConnID, int iLength);
13+
virtual EnHandleResult OnSend(ITcpServer* pSender, CONNID dwConnID, const BYTE* pData, int iLength);
14+
virtual EnHandleResult OnClose(ITcpServer* pSender, CONNID dwConnID, EnSocketOperation enOperation, int iErrorCode);
15+
virtual EnHandleResult OnShutdown(ITcpServer* pSender);
16+
};
17+
18+
int main(int argc, char* const argv[])
19+
{
20+
// 1. Create listener object
21+
CListenerImpl s_listener;
22+
// 2. Create component object (and binding with listener object)
23+
CTcpPullServerPtr s_pserver(&s_listener);
24+
25+
// 3. Start component object
26+
if(!s_pserver->Start("0.0.0.0", 5555))
27+
exit(1);
28+
29+
/* wait for exit */
30+
// ... ...
31+
32+
// 6. (optional) Stop component object
33+
s_pserver->Stop()
34+
35+
return 0;
36+
37+
// 7. Destroy component object automatically
38+
// 8. Destroy listener object automatically
39+
}

Doc/HP-Socket Class Diagram.jpg

1.32 MB
Loading

Doc/HP-Socket Class Diagram.uml

Lines changed: 44104 additions & 0 deletions
Large diffs are not rendered by default.

Doc/HP-Socket Development Guide.pdf

1.61 MB
Binary file not shown.

Doc/HP-Socket HTTP Class Diagram.jpg

872 KB
Loading

Doc/HP-Socket Logo.png

36 KB
Loading

Doc/HP-Socket SSL Class Diagram.jpg

229 KB
Loading

Doc/HP-Socket-Agent-Demo.JPG

115 KB
Loading

Doc/HP-Socket-Agent.JPG

133 KB
Loading

Doc/HP-Socket-Client.JPG

116 KB
Loading

Doc/HP-Socket-Server.JPG

117 KB
Loading

Doc/HTTP Component.jpg

259 KB
Loading

Doc/PUSH-PULL-PACK.jpg

89.8 KB
Loading

Doc/SSL Component.jpg

272 KB
Loading

Linux/Change-APIs.txt

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# ======================================== #
2+
HP-Socket v5.4.3 API Update List:
3+
# ======================================== #
4+
--------------------
5+
1.HTTP:
6+
--------------------
7+
HP_HttpServer_StartHttp (ADD)
8+
HP_HttpServer_SetHttpAutoStart (ADD)
9+
HP_HttpServer_IsHttpAutoStart (ADD)
10+
HP_HttpAgent_StartHttp (ADD)
11+
HP_HttpAgent_SetHttpAutoStart (ADD)
12+
HP_HttpAgent_IsHttpAutoStart (ADD)
13+
HP_HttpClient_StartHttp (ADD)
14+
HP_HttpClient_SetHttpAutoStart (ADD)
15+
HP_HttpClient_IsHttpAutoStart (ADD)
16+
17+
# ======================================== #
18+
HP-Socket v5.4.2 API Update List:
19+
# ======================================== #
20+
--------------------
21+
1.Server / Agent:
22+
--------------------
23+
HP_Server_SetOnSendSyncPolicy (ADD)
24+
HP_Server_GetOnSendSyncPolicy (ADD)
25+
HP_Agent_SetOnSendSyncPolicy (ADD)
26+
HP_Agent_GetOnSendSyncPolicy (ADD)
27+
28+
--------------------
29+
2.SSL:
30+
--------------------
31+
HP_SSLServer_StartSSLHandShake (ADD)
32+
HP_SSLServer_SetSSLAutoHandShake (ADD)
33+
HP_SSLServer_IsSSLAutoHandShake (ADD)
34+
HP_SSLAgent_StartSSLHandShake (ADD)
35+
HP_SSLAgent_SetSSLAutoHandShake (ADD)
36+
HP_SSLAgent_IsSSLAutoHandShake (ADD)
37+
HP_SSLClient_StartSSLHandShake (ADD)
38+
HP_SSLClient_SetSSLAutoHandShake (ADD)
39+
HP_SSLClient_IsSSLAutoHandShake (ADD)
40+
41+
# ======================================== #
42+
HP-Socket v5.4.1 API Update List:
43+
# ======================================== #
44+
--------------------
45+
1. System:
46+
--------------------
47+
SYS_Malloc (ADD)
48+
SYS_Realloc (ADD)
49+
SYS_Free (ADD)
50+
51+
--------------------
52+
2. TCP/UDP:
53+
--------------------
54+
HP_Agent_ConnectWithLocalPort (ADD)
55+
HP_Agent_ConnectWithExtraAndLocalPort (ADD)
56+
HP_Client_StartWithBindAddressAndLocalPort (ADD)
57+
HP_Agent_IsConnected (ADD)
58+
HP_Client_IsConnected (ADD)
59+
HP_Server_IsConnected (ADD)
60+
61+
--------------------
62+
3. Thread Pool:
63+
--------------------
64+
Create_HP_ThreadPool (ADD)
65+
Destroy_HP_ThreadPool (ADD)
66+
Create_HP_SocketTaskObj (ADD)
67+
Destroy_HP_SocketTaskObj (ADD)
68+
HP_ThreadPool_Start (ADD)
69+
HP_ThreadPool_Stop (ADD)
70+
HP_ThreadPool_Submit (ADD)
71+
HP_ThreadPool_Submit_Task (ADD)
72+
HP_ThreadPool_AdjustThreadCount (ADD)
73+
HP_ThreadPool_HasStarted (ADD)
74+
HP_ThreadPool_GetState (ADD)
75+
HP_ThreadPool_GetQueueSize (ADD)
76+
HP_ThreadPool_GetThreadCount (ADD)
77+
HP_ThreadPool_GetMaxQueueSize (ADD)
78+
HP_ThreadPool_GetRejectedPolicy (ADD)
79+
80+
# ======================================== #
81+
HP-Socket v5.2.1 API Update List:
82+
# ======================================== #
83+
84+
1. Add all functions for SSL & HTTP components
85+
86+
# ======================================== #
87+
HP-Socket v1.0.0 API Update List:
88+
# ======================================== #

Linux/ChangeLog.txt

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
==========================================================================================
2+
v5.4.3 Update:
3+
==========================================================================================
4+
5+
> HTTP Components Update
6+
-----------------
7+
1. The HTTP components can manually start HTTP communication to perform pre-operations such as SOCKS proxy server settings for HTTP communication.
8+
2. The HTTP components (Server/Agent/Client) adds the following interface methods to support manual startup of the HTTP communication:
9+
1) StartHttp(): Manually start HTTP communication. When the component is set to non-automatic start, this method needs to be called to start the HTTP communication.
10+
2) SetHttpAutoStart(): Set the component's HTTP start mode (default: TRUE, automatic start).
11+
3) IsHttpAutoStart(): Get the component's HTTP start mode.
12+
13+
> Other Update
14+
-----------------
15+
1. Bug fix: UDP Server may be trigger the OnAccept event repeatedly in high concurrent scenarios
16+
17+
==========================================================================================
18+
v5.4.2 Update:
19+
==========================================================================================
20+
21+
> SSL Components Update
22+
-----------------
23+
1. The SSL components can manually start SSL handshake to perform pre-operations such as proxy server settings for SSL/Https communication.
24+
2. The SSL components (Server/Agent/Client) adds the following interface methods to support manual startup of the SSL handshake:
25+
1) StartSSLHandShake(): Manually start SSL handshake. When the component is set to non-automatic handshake, this method needs to be called to start the SSL handshake.
26+
2) SetSSLAutoHandShake(): Set the component's handshake mode (default: TRUE, automatic handshake).
27+
3) IsSSLAutoHandShake(): Get the component's handshake mode.
28+
29+
> Other Update
30+
-----------------
31+
1. All component interface methods that may cause a Socket to close are asynchronously fired OnClose event in the Socket communication thread.
32+
2. The Disconnect() method of the Server and Agent components no longer supports ‘non-forced disconnects’ (still retains the bForce parameter) and is forced to disconnect when invoked.
33+
3. openssl upgrade to version 1.1.0i
34+
35+
==========================================================================================
36+
v5.4.1 Update:
37+
==========================================================================================
38+
39+
> Add Thread Pool Component
40+
-----------------
41+
1. add IHPThreadPool thread pool component
42+
2. important methods ofIHPThreadPool:
43+
1) Start: startup thread pool
44+
2) Stop: shutdown thread pool
45+
3) Submit: submit task
46+
4) AdjustThreadCount: adjust thread count
47+
48+
> Interface Update
49+
-----------------
50+
1. The Connect() method of IAgent interface adds parameter 'usLocalPort', which can be bound to a local port when connecting
51+
2. The Start() method of IClient interface adds parameter 'usLocalPort', which can be bound to a local port when connecting
52+
3. IClient/IAgent/IServer interfaces add method IsConnected() to detect whether it is valid connection
53+
54+
> Regular Update
55+
-----------------
56+
1. fix known issues
57+
2. performance optimization
58+
59+
==========================================================================================
60+
v5.3.2 Update:
61+
==========================================================================================
62+
63+
> Regular Update
64+
-----------------
65+
1. bug fix: shared library can not be loaded by dlopen() in version 5.3.1
66+
2. jemalloc upgrade to version 5.1.0
67+
68+
==========================================================================================
69+
v5.3.1 Update:
70+
==========================================================================================
71+
72+
> Android NDK supported
73+
-----------------
74+
1. all components are compatible with Android NDK
75+
2. provide _ZLIB_DISABLED precompiled macro to disable zlib functions
76+
3. provide _ICONV_DISABLED precompiled macro to disable iconv functions
77+
78+
> Regular Update
79+
-----------------
80+
1. http-parser upgrade to version 2.8.1, and reference it using source code
81+
2. jemalloc upgrade to version 5.0.1
82+
3. openssl upgrade to version 1.1.0h
83+
84+
==========================================================================================
85+
v5.2.1 Update:
86+
==========================================================================================
87+
88+
> Create HP-Socket SSL Components
89+
-----------------
90+
1. Server: SSL Server, SSL Pull Server, SSL Pack Server
91+
2. Agent: SSL Agent, SSL Pull Agent, SSL Pack Agent
92+
3. Client: SSL Client, SSL Pull Client, SSL Pack Client
93+
94+
> Create HP-Socket HTTP Components
95+
-----------------
96+
1. Server: HTTP Server, HTTPS Server
97+
2. Agent: HTTP Agent, HTTPS Agent
98+
3. Client: HTTP Client, HTTPS Client, HTTP Sync Client, HTTPS Sync Client
99+
100+
> Create Demos:
101+
-----------------
102+
1. testecho-ssl: (SRC) SSL simple test echo server/agent/client
103+
2. testecho-ssl-pfm: (SO) SSL performance test echo server/agent/client
104+
3. testecho-ssl-pull: (SO) SSL pull echo server/agent/client
105+
4. testecho-ssl-pack: (4C SO) SSL pack echo server/agent/client
106+
5. testecho-http: (SRC) HTTP simple test echo server/agent/client/sync-client
107+
6. testecho-http-4c: (4C SO) HTTP simple test echo server/agent/client/sync-client
108+
109+
> Other Updates:
110+
-----------------
111+
1. Version number revision: Use a unified version number for Windows & Linux distribution
112+
2. Code optimization and knowing bug fixed
113+
114+
==========================================================================================
115+
v1.0.0 Update:
116+
==========================================================================================
117+
118+
> Create HP-Socket Basic Components
119+
-----------------
120+
1. Server: TCP Server, TCP Pull Server, TCP Pack Server, UDP Server
121+
2. Agent: TCP Agent, TCP Pull Agent, TCP Pack Agent
122+
3. Client: TCP Client, TCP Pull Client, TCP Pack Client, UDP Client, UDP Cast
123+
124+
> Create Demos:
125+
-----------------
126+
1. testecho: tcp simple test echo server/agent/client
127+
2. testecho-pfm: tcp performance test echo server/agent/client
128+
3. testecho-pull: tcp pull echo server/agent/client
129+
4. testecho-pack: tcp pack echo server/agent/client
130+
5. testecho-udp: udp simple echo server/client/cast
131+
6. testecho-udp-pfm: udp performance test echo server/client
132+
7. testecho-lib: tcp pull echo server/agent/client (use hpsocket.so and hpsocket4c.so)

Linux/LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright JessMA Open Source ([email protected])
3+
*
4+
* Author : Bruce Liang
5+
* Website : http://www.jessma.org
6+
* Project : https://github.com/ldcsaa
7+
* Blog : http://www.cnblogs.com/ldcsaa
8+
* Wiki : http://www.oschina.net/p/hp-socket
9+
* QQ Group : 75375912, 44636872
10+
*
11+
* Licensed under the Apache License, Version 2.0 (the "License");
12+
* you may not use this file except in compliance with the License.
13+
* You may obtain a copy of the License at
14+
*
15+
* http://www.apache.org/licenses/LICENSE-2.0
16+
*
17+
* Unless required by applicable law or agreed to in writing, software
18+
* distributed under the License is distributed on an "AS IS" BASIS,
19+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20+
* See the License for the specific language governing permissions and
21+
* limitations under the License.
22+
*/

Linux/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# HP-Socket for Linx
2+
&nbsp;&nbsp;&nbsp;&nbsp;The exported API of HP-Socket for Linux is consistent with HP-Socket for Windows, but the implementation code is completely separated. HP-Socket for Linux uses the features of the *C++14* standard, and thus needs to be compiled by a compiler which version is *GCC 5.x* and above.
3+
&nbsp;&nbsp;&nbsp;&nbsp;The distribution packages of HP-Socket contains a series of Visual Studio Solutions, which were used to compile HP-Socket components and demos, you can compile them by yourself after install and configure the [*Visual C++ for Linux Development*](https://blogs.msdn.microsoft.com/vcblog/2016/03/30/visual-c-for-linux-development/) plug-in. Of course, you can write your own Makefile file to compile these codes.
4+
&nbsp;&nbsp;&nbsp;&nbsp;Note: the compilation and execution environments of HP-Socket requires Linux kernel version *2.6.32* and above.
5+
## Installation
6+
```
7+
$ sudo ./install.sh -h
8+
Usage: install.sh [...O.P.T.I.O.N.S...]
9+
-----------------+------------------------------------------------
10+
-p|--prefix : install/uninstall path (default: /usr/local)
11+
-l|--libdir : lib dir (default: x86 -> lib, x64 -> lib64)
12+
-d|--with-demo : install demos or not (default: true)
13+
-u|--uninstall : execute uninstall operation from install path
14+
-v|--version : print installing hp-socket version
15+
-h|--help : print this usage message
16+
-----------------+------------------------------------------------
17+
```

0 commit comments

Comments
 (0)