daily pastebin goal
3%
SHARE
TWEET

Untitled

a guest Apr 22nd, 2018 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import socket
  2. import threading
  3.  
  4. HOST = '0.0.0.0'
  5. PORT = 24081
  6. BUFFER_SIZE = 1024
  7.  
  8. def udpServer():
  9.   s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  10.   s.bind((HOST, PORT))
  11.   while True:
  12.     data = s.recvfrom(BUFFER_SIZE)
  13.     if data:
  14.         print('Client to Server: ' , data)
  15.         s.sendto(data[0].upper(), data[1])
  16.   s.close()
  17.  
  18. thread = threading.Thread(target=udpServer)
  19. thread.start()
  20. print ("running...")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top