Python,Windows 和 Raspberry pi 3 之间的套接字

信天翁

所以当我遇到一个奇怪的问题时,我开始倾向于使用套接字。当 Pi 运行我的服务器脚本和我的 Windows 运行我的客户端脚本时,我可以在我的 Window 计算机和我的 Raspberry pi 之间建立连接,但是当我尝试在我的 Windows 上运行服务器脚本和我的 Pi 上的客户端时,它们无法连接(当然是在切换主机之后)。任何人都知道为什么会这样?

#server code
import socket
import time

serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
serversocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

host = '192.168.0.23'
port = 2613

serversocket.bind((host, port))
serversocket.listen(5)
while True:
    clientsocket, addr = serversocket.accept()
    print("Got a connection from %s" % str(addr))
    currentTime = time.ctime(time.time()) + "\r\n"
    clientsocket.send(currentTime.encode('ascii'))
    clientsocket.close()

#client code
import socket

clientsocket = socket.socket()
host = '192.168.0.23'
port = 2613

clientserver.connect((host,port))
print s.recv(1024)
clientserver.close
丹德夫

在您的客户端代码中,您有一个 clientsocket,然后您调用 clientserver 然后调用 s。clientserver 和 s 都未定义。尝试:

#client code
import socket

clientsocket = socket.socket()
host = '192.168.0.23'
port = 2613

clientsocket.connect((host,port))
print (clientsocket.recv(1024))
clientsocket.close

还可以尝试使用管理员权限在 Windows 上运行服务器脚本,以便它可以打开端口并检查 Windows 上的防火墙设置是否为端口 2613。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Raspberry Pi 之间的 Python 套接字连接

来自分类Dev

Raspberry Pi和Arduino中的Web套接字之间的区别

来自分类Dev

Arduino 和 Raspberry pi3 之间的串行通信

来自分类Dev

Raspberry PI 3、SerialPort 和奇怪的响应

来自分类Dev

Raspberry Pi和GitLab

来自分类Dev

NodeJS和Raspberry Pi

来自分类Dev

QEMU和Raspberry Pi

来自分类Dev

使用Raspberry Pi 3,OpenCV和Python的运动跟踪器

来自分类Dev

用于ARM处理器(Raspberry Pi)和python3的psutil的替代

来自分类Dev

使用OpenCV,Python和Raspberry Pi 3的球追踪器(带摄像头模块)

来自分类Dev

Python和TCL之间的套接字连接

来自分类Dev

Python 3 套接字和 QTcpsocket (c++) 之间的通信失败

来自分类Dev

Windows 和 Linux 之间的 Python 套接字连接

来自分类Dev

如何使Raspberry Pi 3可被iOS和CoreBluetooth发现?

来自分类Dev

Raspberry Pi 3上的Streisand Effect和Turnkey Linux

来自分类Dev

Raspberry Pi 3 B 型蓝牙和 Uart (Rx/Tx)

来自分类Dev

Geckodriver 和 Firefox 在 Raspberry Pi 3 上是否兼容?

来自分类Dev

在Raspberry Pi,Arduino和JavaScript之间使用MQTT

来自分类Dev

Raspberry Pi和Arduino之间的串行通信不稳定

来自分类Dev

Raspberry Pi 2和PC之间通过Internet的通信

来自分类Dev

Raspberry Pi备份服务器(Mac和Windows)

来自分类Dev

Python 3多处理和套接字

来自分类Dev

Raspberry Pi 3和XBee S2C之间通过SparkFun的XBee USB软件狗进行串行通信

来自分类Dev

Windows IoT 通过 Raspberry Pi 3 的启动问题

来自分类Dev

在Raspberry PI上使用Python和OpenCV进行图像处理

来自分类Dev

在Raspberry Pi3或/和Pi 0上构建Qt5.6或Qt5.7

来自分类Dev

在Raspberry Pi3或/和Pi 0上构建Qt5.6或Qt5.7

来自分类Dev

Python:OSError:[Errno -9985]在Raspberry PI 3B +上使用Snowboy和SpeechRecognition时设备不可用

来自分类Dev

使用OpenCV,Python,Raspberry Pi 3的Ball Tracker

Related 相关文章

  1. 1

    Raspberry Pi 之间的 Python 套接字连接

  2. 2

    Raspberry Pi和Arduino中的Web套接字之间的区别

  3. 3

    Arduino 和 Raspberry pi3 之间的串行通信

  4. 4

    Raspberry PI 3、SerialPort 和奇怪的响应

  5. 5

    Raspberry Pi和GitLab

  6. 6

    NodeJS和Raspberry Pi

  7. 7

    QEMU和Raspberry Pi

  8. 8

    使用Raspberry Pi 3,OpenCV和Python的运动跟踪器

  9. 9

    用于ARM处理器(Raspberry Pi)和python3的psutil的替代

  10. 10

    使用OpenCV,Python和Raspberry Pi 3的球追踪器(带摄像头模块)

  11. 11

    Python和TCL之间的套接字连接

  12. 12

    Python 3 套接字和 QTcpsocket (c++) 之间的通信失败

  13. 13

    Windows 和 Linux 之间的 Python 套接字连接

  14. 14

    如何使Raspberry Pi 3可被iOS和CoreBluetooth发现?

  15. 15

    Raspberry Pi 3上的Streisand Effect和Turnkey Linux

  16. 16

    Raspberry Pi 3 B 型蓝牙和 Uart (Rx/Tx)

  17. 17

    Geckodriver 和 Firefox 在 Raspberry Pi 3 上是否兼容?

  18. 18

    在Raspberry Pi,Arduino和JavaScript之间使用MQTT

  19. 19

    Raspberry Pi和Arduino之间的串行通信不稳定

  20. 20

    Raspberry Pi 2和PC之间通过Internet的通信

  21. 21

    Raspberry Pi备份服务器(Mac和Windows)

  22. 22

    Python 3多处理和套接字

  23. 23

    Raspberry Pi 3和XBee S2C之间通过SparkFun的XBee USB软件狗进行串行通信

  24. 24

    Windows IoT 通过 Raspberry Pi 3 的启动问题

  25. 25

    在Raspberry PI上使用Python和OpenCV进行图像处理

  26. 26

    在Raspberry Pi3或/和Pi 0上构建Qt5.6或Qt5.7

  27. 27

    在Raspberry Pi3或/和Pi 0上构建Qt5.6或Qt5.7

  28. 28

    Python:OSError:[Errno -9985]在Raspberry PI 3B +上使用Snowboy和SpeechRecognition时设备不可用

  29. 29

    使用OpenCV,Python,Raspberry Pi 3的Ball Tracker

热门标签

归档