[英]TimeoutError: [Errno 60] Operation timed out (Python socket request)
I am fairly new to Python (just started today) but am really struggling with this:我对 Python 还很陌生(今天才开始),但我真的很挣扎:
#! /usr/bin/python
import socket
s=socket.socket()
s.connect(("<my ip addres>", 22))
answer=s.recv(1024)
print(answer)
s.close
I believe I am meant to be getting some sort of 'banner' response but it gives nothing for a few minutes before spouting the following error: TimeoutError: [Errno 60] Operation timed out我相信我应该得到某种“横幅”响应,但在发出以下错误之前的几分钟内它什么也没给出: TimeoutError:[Errno 60] Operation timed out
Why would this be happening?为什么会发生这种情况?
First of all make sure you connect to port 22. Then make sure your operating system's firewall doesn't block incoming connections to port 22. In case the address you have configured for the server is "localhost" and try to connect from another machine you won't be able to connect.首先确保您连接到端口 22。然后确保您的操作系统的防火墙不会阻止到端口 22 的传入连接。如果您为服务器配置的地址是“localhost”并尝试从另一台机器连接您将无法连接。 In that case you shoud use "" as ip address.
在这种情况下,您应该使用“”作为 IP 地址。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.