python> udp> echo server

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

python> udp> echo server
DNS server in Python ....
RPi2 / python> UDP transmission
Local server with python
UDP simultaneous connection with Python
Easy HTTP server with Python
Simple HTTP Server for python
Python server settings (nginx + Gunicorn)
Install Python3 on Sakura server (FreeBSD)
Python
Write an HTTP / 2 server in Python
Behavior of python3 by Sakura's server
CGI server (1) python edition in one line
[In-Database Python Analysis Tutorial with SQL Server 2017]
Build CGI Server running on Python 3 on Docker
Push notification from Python server to Android
Python execution server construction (Python + uWSGI + Django + Nginx)
Python development server construction procedure (AWS + Anaconda)
Install Python3 on mixhost server [Currently NG]
Run python wsgi server on NGINX Unit