Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects, and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Developer articles
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
ItJava
Python24
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
Python24
/
03Thread
/
day01
/
basic01.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
46 lines (32 loc) · 1.89 KB
master
Breadcrumbs
Python24
/
03Thread
/
day01
/
basic01.py
Copy path
Top
File metadata and controls
Code
Blame
46 lines (32 loc) · 1.89 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
TCP 三次握手原理:
1- client -> server 我可以和你吃饭吗? server收到客户端的SYN
2- server -> client 好的 回复ACK允许建立连接
3- client -> server 开始发送信息
如果缺少第三部,客户端迟迟没有开始通信,称为未完成三次握手的半链接状态
服务器一般有未完成三次握手的队列和完成三次握手的队列
第三部完成后,系统将半连接的客户端连接从未完成队列移动到已完成的队列中
listen(128)的参数,不同平台参数的表示含义不同
linux中已完成三次握手的队列长度
在其他平台一般指 未完成 + 已完成队列的中长度
accept的含义:从已完成的队列中取出一个客户端进行服务
"""
"""
Tcp四次挥手拜拜断开连接close的原理:(断开连接会有30s-2min的延迟想一会的断开时间)
1- 一端 -> 另一端 咱们分手吧 发送FIN和ACK
2- 另一端 -> 一端 会想一会,发送ACK
3- 另一端 -> 一端 会想一会,发送FIN
4- 一端 -> 另一端 好的,断开连接通知对方,发送ACK
# 设置socket断开连接的选项,close的时候会立即释放,答应断开分手,1表示确定,0为取消
server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
"""
"""
TCP/IP协议并不是单一的协议,而是一族协议
在TCP/IP协议中简单的划分了四层:应用层,运输层,网际层,网络接口层
而在OSI协议中有7层:应用层,表示层,会话层,传输层,网络层,数据链路层,物理层
"""
"""
1- 并发: 多个任务在**同一时间段**执行,每个任务分配时间段执行,来回切换
2- 并行: 发生在多核cpu,多个任务在**同一时间点**执行
网站的并发量是多少:意思就是在一段时间段内的请求数量是多少
"""
You can’t perform that action at this time.