简体   繁体   English

从客户端连接到具有相同网络的服务器

[英]From client connect with server with the same network

I have this code to connect with server like this: 我有这个代码连接服务器像这样:

This is file server.py 这是文件server.py

host = "192.168.0.91"
port = 5004

s = socket.socket()
s.bind((host,port))

s.listen(5)

print("Server Started.")

But when I run it, it showed me an error 但是当我运行它时,它显示了一个错误

File "D:/odoo11new/server.py", line 61, in Main
s.bind((host,port))
OSError: [WinError 10049] The requested address is not valid in its context

How can i fix that problem :( any suggest for me? Thanks in advance 我该如何解决这个问题:(对我有任何建议?提前谢谢

You tried to bind the host which wasn't set up on your server. 您试图绑定未在服务器上设置的主机。
Check host via ipconfig 通过ipconfig检查主机
Or bind any host like this: 或绑定任何主机,如下所示:

host = "0.0.0.0"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 python连接到同一网络上的服务器 - python connect to server on same network 即使在同一网络上也无法从外部连接到Apache服务器 - Cannot connect to Apache server from outside even on the same network 从同一网络上的其他设备连接到 Flask 服务器 - Connect to Flask Server from other devices on same network 如何使用套接字编程将 android 手机客户端连接到同一网络上的 python 服务器? - How to connect android phone client to python server on same network using socket programming? 允许同一用户从Angular2客户端和其他Django服务器连接到Django服务器 - Allow same user to connect to Django server from Angular2 client and other Django server 将Thrift客户端连接到同一主机上单独的docker容器中的Thrift服务器 - Connect a Thrift client to a Thrift server in separate docker containers on the same host 将MySql连接到同一网络的机器上 - Connect MySql to a machine on the same network 连接到服务器的客户端IP - IP of client that connect to server 如何使用IP地址从Heroku中的客户端连接服务器 - How to connect server from client in Heroku using IP address 从同一网络上的另一台计算机(flask python 服务器)访问本地主机? - Access localhost from another computer on the same network (flask python server)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM