栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

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

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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.



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/638007.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号