socket.error:[errno 99]无法在python中分配请求的地址和名称空间

socket.error:[errno 99]无法在python中分配请求的地址和名称空间,第1张

socket.error:[errno 99]无法在python中分配请求的地址和名称空间

简而言之,这就是您要测试的内容:

import socketserver = socket.socket() server.bind(("10.0.0.1", 6677)) server.listen(4) client_socket, client_address = server.accept()print(client_address, "has connected")while 1==1:    recvieved_data = client_socket.recv(1024)    print(recvieved_data)

假设有一些事情,这可以工作:

  1. Your local IP address (on the server) is 10.0.0.1 (This video shows you how)
  2. No other software is listening on port 6677
Also note the basic concept of IP addresses:

Try the following, open the start menu, in the “search” field type

cmd
and
press enter. once the black console opens up type
ping www.google.com
and
this should give you and IP address for google. This address is googles local
IP and they bind to that and obviously you can not bind to an IP address
owned by google.

With that in mind, you own your own set of IP addresses. First you have the
local IP of the server, but then you have the local IP of your house. In the
below picture

192.168.1.50
is the local IP of the server which you can bind
to. You still own
83.55.102.40
but the problem is that it’s owned by the
Router and not your server. So even if you visit
http://whatsmyip.com and that tells you that your IP
is
83.55.102.40
that is not the case because it can only see where you’re
coming from.. and you’re accessing your internet from a router.

In order for your friends to access your server (which is bound to

192.168.1.50
) you need to forward port
6677
to
192.168.1.50
and this is
done in your router. Assuming you are behind one.

If you’re in school there’s other dilemmas and routers in the way most likely.



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5643827.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存