Guest User

Untitled

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