]> source.dussan.org Git - rspamd.git/commitdiff
[Test] Add dummy udp client
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 21 Jan 2019 16:26:41 +0000 (16:26 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 21 Jan 2019 16:26:41 +0000 (16:26 +0000)
test/functional/util/dummy_udp.py [new file with mode: 0644]

diff --git a/test/functional/util/dummy_udp.py b/test/functional/util/dummy_udp.py
new file mode 100644 (file)
index 0000000..9946b50
--- /dev/null
@@ -0,0 +1,19 @@
+import socket
+import sys
+
+UDP_IP = "127.0.0.1"
+
+if __name__ == "__main__":
+    alen = len(sys.argv)
+    if alen > 1:
+        port = int(sys.argv[1])
+    else:
+        port = 5005
+    sock = socket.socket(socket.AF_INET, # Internet
+                         socket.SOCK_DGRAM) # UDP
+    sock.bind((UDP_IP, port))
+
+    while True:
+        data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes
+        print "received message:", data
+        sock.sendto(data, addr)
\ No newline at end of file