简体   繁体   English

Errno111 连接被拒绝 Kivy 套接字错误

[英]Errno111 Connection Refused Kivy Socket Error

I am a new beginner in kivy I am developing a app that connect to my windows pc using python sockets我是 kivy 的新初学者 我正在开发一个应用程序,该应用程序使用 python ZFFE33A13F6E35006DABAB7D7F6E35004windows 电脑连接到我的电脑

This is my Kivy App code:这是我的 Kivy 应用程序代码:

import kivy
from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
import socket

class FloatLay(FloatLayout):
    def Connect(self):
        try:
            s = socket.socket()
            hostname = '127.0.0.1'
            port = 8080
            s.connect((hostname, port))
        except Exception as e:
            self.ids.text.text = str(e)


class MyApp(App):
    def build(self):
        return FloatLay()


if __name__ == "__main__":
    MyApp().run()

This is my.kv kivy file这是 my.kv kivy 文件

<FloatLay>:
    Button:
        text:"Connect"
        pos_hint:{"x":0.6,"top":0.5}
        size_hint:0.1,0.05
        on_press: root.Connect()
    Label:
        id:text
        text:"Connect Status"
        pos_hint:{"x":0.2,"top":0.5}
        size_hint:0.4,0.05

This is my Socket_Server这是我的 Socket_Server

import socket
def main():
 while True:
    running=False
    listensocket = socket.socket() 
    Port = 8080 
    maxConnections = 999
    IP = '127.0.0.1' #IP address of local machine
    listensocket.bind((IP,Port))
    listensocket.listen(maxConnections)
    print("Server started at " + IP + " on port " + str(Port))
    (clientsocket, address) = listensocket.accept()
    print("New connection made!")

    running = True
    try:
        while running:
            message = clientsocket.recv(1024).decode()
            print(message)
    except:
        print('')
main()

Whenever I run the code their is a error named Connection Refused每当我运行代码时,它们都会出现一个名为 Connection Refused 的错误

I dont think their is a mistake in my code as when i run the Client code and the Server on my windows pc at the same time they both are connected.我不认为它们是我的代码中的错误,因为当我在我的 windows pc 上同时运行客户端代码和服务器时,它们都已连接。

Note:I am running the App on a android device and the code on a windows pc注意:我在 android 设备上运行应用程序,在 windows 电脑上运行代码

I have got the solution for this if you are using windows then follow these steps:如果您使用的是 windows,我已经找到了解决方案,然后按照以下步骤操作:

  1. Open command prompt打开命令提示符
  2. Type ipconfig ipconfig
  3. Find the IPv4 in Wireless LAN adapter Wi-Fi sectionWireless LAN adapter Wi-Fi部分中找到 IPv4
  4. Copy it and paste your IPv4 as a string to the IP vairable.复制它并将您的 IPv4 作为字符串粘贴到 IP 变量中。

Note: Dont add any spaces while typing the IP注意:输入 IP 时不要添加任何空格

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 urlopen 错误 [errno 111] 连接被拒绝 - urlopen error [errno 111] connection refused AndroidViewClient中的Culebra返回“ RuntimeError:错误:连接到 - Culebra in AndroidViewClient returns "RuntimeError: ERROR: Connecting to <socket… [Errno 111] Connection refused SocketException:连接被拒绝(操作系统错误:连接被拒绝,errno = 111),地址 = localhost,端口 = 44382 - SocketException: Connection refused (OS Error: Connection refused, errno = 111), address = localhost, port = 44382 模拟器:连接至套接字“ 127.0.0.1:1970”时出错:111-&gt;连接被拒绝 - emulator: Error while connecting to socket '127.0.0.1:1970': 111 -> Connection refused 未处理的异常:SocketException:操作系统错误:连接被拒绝,errno = 111,地址 = 127.0.0.1,端口 = 40712 - Unhandled Exception: SocketException: OS Error: Connection refused, errno = 111, address = 127.0.0.1, port = 40712 如何解决Indy套接字错误#111 Delphi 2007服务器与RAD XE7客户端之间的连接被拒绝? - How to solve Indy socket error #111 connection refused between Delphi 2007 server and RAD XE7 client? ubuntu:所有android模拟器(x86和arm)卡在“连接到套接字时出错&#39;127.0.0.1:1970&#39;:111 - &gt;连接被拒绝” - ubuntu: all android emulator(x86 and arm) stuck on “Error while connecting to socket '127.0.0.1:1970': 111 -> Connection refused” Android套接字连接拒绝错误 - Android socket connection refused error Flutter “连接被拒绝” (errno=111) 尝试发送 http 获取请求以从物理设备到 pc - Flutter “Connection Refused” (errno=111) when trying to send an http get request to from physical device to pc Android Socket连接遭拒绝 - Android Socket connection refused
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM