Operation check
CentOS 6.5
I made it with Unity (C #) etc., but it is a python version of the echo server with UDP port. (I made Qiita search)
What was sent to port 6000 is returned.
udpEcho.py
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind(('',6000))
s.setblocking(0)
data =''
address = ''
while True:
try:
data,address = s.recvfrom(120)
except socket.error:
pass
else:
print "from:", address
print "recvd:", data
s.sendto("recvd:" + data, address)
result
$ python udpEcho.py
from: ('192.168.124.132', 55989)
recvd: aaaaa
Characters such as recvd: aaaaa
are echoed back to the UDP source.
Recommended Posts