Guest User

Untitled

a guest
Nov 27th, 2018
80
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import socket
  2. import sys
  3.  
  4.  
  5.  
  6. def main():
  7. HOST = '::'
  8. PORT = 32323
  9. res = socket.getaddrinfo(HOST, PORT, socket.AF_INET6, socket.SOCK_DGRAM, 0, socket.AI_PASSIVE)
  10. af, socktype, proto, canonname, sa = res[0]
  11. try:
  12. s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
  13. s.bind(sa)
  14. while True:
  15. data, addr = s.recvfrom(1024)
  16. if not data:
  17. break
  18. print 'server received %r from %r' % (data, addr)
  19. s.sendto(data, addr)
  20. s.close()
  21. except socket.error, msg:
  22. print msg
  23.  
  24.  
  25.  
  26. if __name__ == '__main__':
  27. main()
RAW Paste Data