Update 14.网络编程入门和网络应用开发.md

监听127.0.0.1避免192.168.1.2不是本机IP而报错的情况
pull/548/head
doublepi123 2020-04-18 16:01:00 +08:00 committed by GitHub
parent 05998c86e8
commit 77a4947ecd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -151,7 +151,7 @@ def main():
server = socket(family=AF_INET, type=SOCK_STREAM)
# 2.绑定IP地址和端口(端口用于区分不同的服务)
# 同一时间在同一个端口上只能绑定一个服务否则报错
server.bind(('192.168.1.2', 6789))
server.bind(('127.0.0.1', 6789))
# 3.开启监听 - 监听客户端连接到服务器
# 参数512可以理解为连接队列的大小
server.listen(512)