This is a simple UDP-server example in Python. Run and connect with nc -u 127.0.0.1 2608.
from socket import * # Serverparameters TheServerHost = "localhost" ListeningPort = 2608 BufferSize = 1024 address = (TheServerHost, ListeningPort) # Sockets UDPSock = socket(AF_INET, SOCK_DGRAM) UDPSock.bind(address) # Answer calls from client while 1: data,address = UDPSock.recvfrom(BufferSize) # If there is data awaiting if data: # echo UDPSock.sendto(data + '\n', address)
TCP? See this post.