RPi2 / python> UDP transmission

Operation check


Sender: RaspberryPi2 + raspbian
Receiver: CentOS 6.5 (32bit) [IP: 192.168.10.8]

Send from RPi2 with python script on UDP port and confirm receipt on CentOS.

The python script for RPi2 is below.

Reference 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))

Reception result on CentOS side.

# 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.........

The character string from RPi2 has been received.

Recommended Posts

RPi2 / python> UDP transmission
python> udp> echo server
UDP simultaneous connection with Python
Python
[50 counts] Key transmission using Python for Windows