Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. import socket
  2.  
  3.  
  4. class UDP_server:
  5.     def __init__(self):
  6.         self.listenToClient()
  7.  
  8.     def listenToClient(self):
  9.         with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as sock:
  10.             sock.bind(("localhost", 14567))
  11.             page = ""
  12.             while True:
  13.                 data, addr = sock.recvfrom(1024)
  14.                 page = page + data.decode("utf-8")
  15.             print(page)
  16.  
  17.  
  18. if __name__ == "__main__":
  19.     UDP_server().__init__()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement