添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
坏坏的煎饼果子  ·  Databricks Runtime ...·  1小时前    · 
旅途中的羊肉串  ·  WPF ...·  1 年前    · 
飘逸的山羊  ·  WPF GroupBox ...·  1 年前    · 

Python ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。

Stakeoverflow相关问题链接: stackoverflow.com/quest

解决方案

Instead of

host = socket.gethostname() #Get the local machine name
port = 12397 # Reserve a port for your service
s.bind((host,port)) #Bind to the port

you should try

port = 12397 # Reserve a port for your service
s.bind(('', port)) #Bind to the port

so that the listening socket isn't too restricted. Maybe otherwise the listening only occurs on one interface which, in turn, isn't related with the local network.

One example could be that it only listens to 127.0.0.1 , which makes connecting from a different host impossible.

意思就是如果bind方法里的第一个ip绑定了127.0.0.1,就只能监听从127.0.0.1发送过来的数据,留成空字符串就可以正常使用了。

发布于 2022-02-23 18:46