简体   繁体   English

无法通过插槽将同一局域网中的两台计算机连接起来

[英]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.

相关问题 Python Sockets:如何在同一 wifi 上的两台计算机之间进行连接 - Python Sockets: how to connect between two computers on the same wifi 使用python套接字在连接到同一wifi的不同计算机上的服务器和客户端之间进行聊天 - chat between server and a client in different computers connected to the same wifi using python sockets 通过局域网中的Python套接字在两台计算机之间进行通信失败 - communication between two computers via Python socket in a LAN failed 计算机之间的套接字 - Sockets between computers Python:通过套接字在两台计算机之间发送数据 - Python: sending data between two computers via sockets 如何在python中的两台连接的计算机之间传输文件? - How to transfer a file between two connected computers in python? 如何使用 PYTHON SOCKETS 在同一网络中的两个设备之间建立连接? - How to establish a connection between two devices in the same network with PYTHON SOCKETS? 两台计算机之间的套接字编程 - Socket programming between two computers 如何使用 Python sockets 连接互联网上的两台计算机? - How to connect two computers on the internet using Python sockets? 如何使用 Python 中的 sockets 连接全球网络上的两台随机计算机 - How to connect two random computers on global network using sockets in Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM