无法设法运行2人Python游戏

时间:2017-05-10 07:21:13

标签: python python-3.x pygame

我试图在一个教程中看到游戏(实际上至少在我的计算机上运行它)。不幸的是,他们的论坛不经常访问,所以也许在这里我可以找到解决方案。

但是当我尝试在连接到一个Wi-fi的不同计算机上运行它时,第二台计算机上的客户端(本地服务器位于第一台)上找不到服务器: 我这样做:

Start server and set to localhost:8000
Start the first client and type localhost:8000, after what it connects to server
In cmd type ipconfig, find IPv4, 
Start the second client, and type [IPv4]:8000, but it isn't connecting to server

我有什么办法让它发挥作用?

以下是我的代码示例:

Client

Server

如果需要,我也可以共享PodSixNet文件。

1 个答案:

答案 0 :(得分:2)

在评论中与您进行调查后,现在很清楚您的服务器正在本地环回(即[IPv4])上运行,因此您无法从其他界面访问它(例如0.0.0.0:8000)。

运行服务器时,应将其设置为localhost:8000(表示所有接口,端口8000)而不是func removeItemForDocument(itemName:String, fileExtension: String) { let fileManager = FileManager.default let NSDocumentDirectory = FileManager.SearchPathDirectory.documentDirectory let NSUserDomainMask = FileManager.SearchPathDomainMask.userDomainMask let paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true) guard let dirPath = paths.first else { return } let filePath = "\(dirPath)/\(itemName).\(fileExtension)" do { try fileManager.removeItem(atPath: filePath) } catch let error as NSError { print(error.debugDescription) }}