2
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

RPi2 / python > UDP送信

Last updated at Posted at 2015-11-08
動作確認
送信側: RaspberryPi2 + raspbian
受信側: CentOS 6.5 (32bit) [IP: 192.168.10.8]

RPi2からpythonスクリプトでUDPポートでの送信をして、受信確認をCentOSでする。

RPi2のpythonスクリプトは以下。

参考 https://wiki.python.org/moin/UdpCommunication

151108c.py
import socket

dstip = "192.168.10.8"
dstport = 6000
message = "from RPi2"

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(message, (dstip, dstport))

CentOS側の受信結果。

# tcpdump -A -n udp portrange 6000
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
22:44:27.881942 IP 192.168.10.5.38422 > 192.168.10.8.6000: UDP, length 9
E..%..@.@.....
...
....p..DLfrom RPi2.........

from RPi2という文字列が受信できている。

2
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?