From 2674003f7c29b0cc5b21f5dfd6cbddb11cb60950 Mon Sep 17 00:00:00 2001 From: tkl Date: Sun, 14 Aug 2016 05:21:04 +0000 Subject: [PATCH] udp example --- udp_socket_server.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 udp_socket_server.py diff --git a/udp_socket_server.py b/udp_socket_server.py new file mode 100755 index 0000000..ad3fac4 --- /dev/null +++ b/udp_socket_server.py @@ -0,0 +1,21 @@ +#!/usr/bin/python2 + +import socket +import thread + +#host = socket.gethostname() +host = "192.168.178.21" +port = 5005 + +def main(): + s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + s.bind((host,port)) + + while 1: + data, addr = s.recvfrom(1024) + print data + print addr + +if __name__ == "__main__": + main() +