当前位置: 首页 > 图灵资讯 > 行业资讯> python socket的连接步骤

python socket的连接步骤

发布时间:2024-06-24 13:36:54

1、服务器监控,即服务器等待他人连接。

2、客户端请求,告诉服务器的具体需求或想要实现的事情。

3、连接确认,等待服务器和客户端确认连接。

实例

classsocket(_socket.socket):
"""Asubclassof_socket.socketaddingthemakefile()method."""
__slots__=["__weakref__","_io_refs","_closed"]

def__init__(self,family=AF_INET,type=SOCK_STREAM,proto=0,fileno=None):
#family和type有默认值,默认为TCP通信建立在服务器之间。
#AF_INET:服务器之间的通信(ipv4)
#AF_INET6:服务器之间的通信(ipv6)
#AF_UNIX:Unix不同过程之间的通信
#SOCK_STREAM:建立TCP时的参数
#SOCK_Dgram:构建UDP时的参数
_socket.socket.__init__(self,family,type,proto,fileno)
self._io_refs=0
self._closed=False

以上是python socket的连接步骤,希望对大家有所帮助。更多Python学习指导:python基础教程

本文教程操作环境:windows7系统Python 3.9.1,DELL G3电脑。

相关文章

python3兼容python2吗

python3兼容python2吗

2025-05-09
python3 whl怎么安装

python3 whl怎么安装

2025-05-09
python 字典怎么提取value

python 字典怎么提取value

2025-05-09
python 怎样计算字符串的长度

python 怎样计算字符串的长度

2025-05-09
python 怎么样反向输出字符串

python 怎么样反向输出字符串

2025-05-09
python 怎么判断字符串开头

python 怎么判断字符串开头

2025-05-09