[英]Cant be connected between two computers in the same Lan with sockets
I have a server-client that work wonderfull when im trying to use them on my own machine. 当我尝试在自己的计算机上使用它们时,我有一个工作出色的服务器客户端。 But - when im trying to use them on two different machines on the same Lan, it didnt work! 但是-当我试图在同一Lan的两台不同机器上使用它们时,它没有用! Here is my connection: 这是我的联系:
Lan = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Creates the socket object
Lan.connect(('localhost', port))
I dont understand why should it be a problem 我不明白为什么会出现问题
When you are binding your socket, it gets bound to certain network interfaces, one of which is the loopback interface which is only available from your local computer. 绑定套接字时,它会绑定到某些网络接口,其中之一是环回接口,该接口只能在本地计算机上使用。 You're likely not binding to your actual network interface controller (NIC) 您可能未绑定到实际的网络接口控制器(NIC)
You want INADDR_ANY when you bind, though you didn't say what programming language, so I don't know specifically how to tell you to do it. 绑定时需要INADDR_ANY,尽管您没有说什么编程语言,所以我不知道如何告诉您这样做。
More info here: 更多信息在这里:
understanding INADDR_ANY for socket programming - c 了解INADDR_ANY进行套接字编程-c
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.