SHARE
TWEET

Server UDP

a guest Jan 23rd, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import socket
  2. import pickle
  3. # Create a UDP socket
  4. sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  5.  
  6. # Bind the socket to the port
  7. server_address = ('0.0.0.0', 10000)
  8. print('starting up on {} port {}'.format(*server_address))
  9. sock.bind(server_address)
  10.  
  11. while True:
  12.     print('\nwaiting to receive message')
  13.     data, address = sock.recvfrom(4096)
  14.    
  15.     data = pickle.loads(data)
  16.     print(data)
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