46 lines
1.4 KiB
Markdown
46 lines
1.4 KiB
Markdown
|
|
# Example and Demos Directory Structure
|
||
|
|
|
||
|
|
This directory contains example code and demonstration scripts organized by protocol type.
|
||
|
|
|
||
|
|
## Directory Structure
|
||
|
|
|
||
|
|
```
|
||
|
|
example_and_demos/
|
||
|
|
├── http/ # HTTP相关的示例和演示
|
||
|
|
│ ├── http_client_example.py # HTTP客户端示例
|
||
|
|
│ └── run_http_server.py # HTTP服务器启动脚本
|
||
|
|
└── socket/ # Socket相关的示例和演示
|
||
|
|
├── run_socket_server.py # 简化版Socket服务器启动脚本
|
||
|
|
└── socket_client_example.py # 简化版Socket客户端示例
|
||
|
|
```
|
||
|
|
|
||
|
|
## Usage
|
||
|
|
|
||
|
|
### HTTP Examples
|
||
|
|
- **HTTP Client Example**: `python example_and_demos/http/http_client_example.py`
|
||
|
|
- **HTTP Server**: `python example_and_demos/http/run_http_server.py`
|
||
|
|
|
||
|
|
### Socket Examples
|
||
|
|
- **Simple Socket Server**: `python example_and_demos/socket/run_socket_server.py`
|
||
|
|
- **Simple Socket Client**: `python example_and_demos/socket/socket_client_example.py`
|
||
|
|
|
||
|
|
## Quick Start
|
||
|
|
|
||
|
|
Use the main quick start script at project root:
|
||
|
|
```bash
|
||
|
|
python quick_start.py
|
||
|
|
```
|
||
|
|
|
||
|
|
Or use the Socket-specific quick start:
|
||
|
|
```bash
|
||
|
|
python quick_start_socket.py
|
||
|
|
```
|
||
|
|
|
||
|
|
## Performance Comparison
|
||
|
|
|
||
|
|
Socket implementation shows **13x performance improvement** over HTTP:
|
||
|
|
- HTTP: 4.13ms average latency, 242 QPS
|
||
|
|
- Socket: 0.31ms average latency, 3,242 QPS
|
||
|
|
|
||
|
|
For performance testing, see `/test/` directory (test_stress.py).
|